Skip to content

Commit

Permalink
add lightSpeed query parameter, #71
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Sep 22, 2021
1 parent 01ed634 commit c6690da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions js/common/GeometricOpticsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const GeometricOpticsConstants = {
ORIGIN_POINT: new Vector2( 1024 / 2, 618 / 2 - 50 ), // view position of the model origin (0,0)
NOMINAL_VIEW_MODEL_CONVERSION: 2, // view coordinates per cm in initial zoom level

LIGHT_SPEED: 500, // speed in centimeter per second for light for the purpose of the animation
RAYS_ANIMATION_TIME: 5, // length of the rays animation, in seconds
RAYS_ANIMATION_TIME: 10, // length of the rays animation, in seconds

//----------------------------------------------------------------------------------------
// LENS
Expand Down
7 changes: 7 additions & 0 deletions js/common/GeometricOpticsQueryParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ const GeometricOpticsQueryParameters = QueryStringMachine.getAll( {
// show the position of points at a distance 2f from the optic.
show2fPoints: {
type: 'flag'
},

// speed of light in centimeters per second, for the purpose of the light rays animation
lightSpeed: {
type: 'number',
defaultValue: 500,
isValidValue: value => ( value >= 100 )
}
} );

Expand Down
4 changes: 2 additions & 2 deletions js/common/model/LightRay.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import Shape from '../../../../kite/js/Shape.js';
import AssertUtils from '../../../../phetcommon/js/AssertUtils.js';
import geometricOptics from '../../geometricOptics.js';
import GeometricOpticsConstants from '../GeometricOpticsConstants.js';
import GeometricOpticsQueryParameters from '../GeometricOpticsQueryParameters.js';
import Optic from './Optic.js';
import Ray from './Ray.js';

Expand Down Expand Up @@ -50,7 +50,7 @@ class LightRay {
this.virtualShape = new Shape();

// {number} maximum travel distance if ray is unimpeded
const distanceTraveled = GeometricOpticsConstants.LIGHT_SPEED * time;
const distanceTraveled = GeometricOpticsQueryParameters.lightSpeed * time;

// {Vector2|null} first intersection point - a null value implies that the initialRay does not intersect the optic
const firstPoint = this.getFirstPoint( initialRay, optic, isPrincipalRayMode );
Expand Down

0 comments on commit c6690da

Please sign in to comment.