Published unlisted
Edited
Jun 11, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof polarizerPolarization = DOM.range(-Math.PI/2, Math.PI/2, 0.01)
//viewof polarizerPolarization = DOM.range(-Math.PI/2, 0, 0.01)
Insert cell
Insert cell
Insert cell
handleWavePolChange = {
//Handle changes to the original wave polarization
const angleBefore = parseFloat(wavePolarization); //user input for initial wave polarization
const angleForRGB = Math.abs(angleBefore/(Math.PI/2)); //normalize for making color gradient
//const angleForRGB = (angleBefore+Math.PI/2)/(Math.PI);
for (let wave of waveArray) {
wave.rotation.x = angleBefore; //rotate wave
wave.material.color.setRGB(0.5,0.7,angleForRGB); //set color on gradient
}
for (let shadow of shadowArrayOld) {
shadow.rotation.x = angleBefore;
shadow.material.color.setRGB(0.5,0.7,angleForRGB);
}
}
Insert cell
handlePolPolChange = {
//Handle changes to the polarization of the polarizer
const angleBefore = parseFloat(wavePolarization);
const angleAfter = parseFloat(polarizerPolarization); //user input for polarizer polarization
const angleDiff = angleBefore - angleAfter; //difference in wave and polarizer angle
const ampAfter = (Math.cos(angleDiff)); //scaling amplitude of sine wave via Malus' law (amp scales as sqrt of intensity)
//const angleForRGB = (angleAfter+Math.PI/2)/(Math.PI); //**** I changed this one
const angleForRGB = Math.abs(angleAfter/(Math.PI/2));
polarizerLines.rotation.x = angleAfter; //rotate polarizer
for (let wave of waveArrayNew) {
if (angleDiff === 1.57 || angleDiff + Math.PI/2 === 0) {
scene.remove(wave); //doesn't return sine wave after polarizer if angle difference is pi/2
} else {
scene.add(wave);
wave.scale.set(1,ampAfter,1); //change wave amplitude based on Malus' law
wave.rotation.x = angleAfter;
wave.material.color.setRGB(0.5,0.7,angleForRGB);
}
}
for (let shadow of shadowArrayNew) {
shadow.rotation.x = angleAfter;
shadow.scale.set(1,ampAfter,1);
shadow.material.color.setRGB(0.5,0.7,angleForRGB);
}
finalPlane.rotation.x = angleAfter;
finalPlaneBoundary.rotation.x = angleAfter;
finalPlaneBoundary.material.color.setRGB(0.5,0.7,angleForRGB);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more