phetsims / bending-light

"Bending Light" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/bending-light
GNU General Public License v3.0
8 stars 8 forks source link

Should the model be in nanometers? #411

Open samreid opened 1 year ago

samreid commented 1 year ago

For https://github.com/phetsims/bending-light/issues/389 I have tried to put the model in nanometers. It is currently a mix of meters and nanometers. Here's my patch:

```diff Index: js/common/model/BendingLightModel.ts IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/js/common/model/BendingLightModel.ts b/js/common/model/BendingLightModel.ts --- a/js/common/model/BendingLightModel.ts (revision 1291e777f49c5f62c6dc7aedcd4bdbf6935efe0d) +++ b/js/common/model/BendingLightModel.ts (date 1662758146463) @@ -74,9 +74,10 @@ // Whether the laser is Ray or Wave mode this.laserViewProperty = new EnumerationProperty( LaserViewEnum.RAY ); - this.wavelengthProperty = new NumberProperty( BendingLightConstants.WAVELENGTH_RED, { + this.wavelengthProperty = new NumberProperty( BendingLightConstants.WAVELENGTH_RED * 1E9, { tandem: tandem.createTandem( 'wavelengthProperty' ), - range: new Range( BendingLightConstants.LASER_MIN_WAVELENGTH * 1E-9, BendingLightConstants.LASER_MAX_WAVELENGTH * 1E-9 ) + units: 'nm', + range: new Range( BendingLightConstants.LASER_MIN_WAVELENGTH, BendingLightConstants.LASER_MAX_WAVELENGTH ) } ); this.isPlayingProperty = new BooleanProperty( true ); this.speedProperty = new EnumerationProperty( TimeSpeed.NORMAL ); ```

The sim is running and not crashing, but the transmitted angle is incorrect (doesn't vary correctly with the input wavelength). I've been working on this a while and starting to wonder if I should just (a) leave it in meters or (b) build an adapter that displays in studio in nm. We previously agreed that studio values should show the units of the sim. Or I could keep trying to figure this out.