Skip to content

Commit

Permalink
improve variable names, see #65
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Dec 9, 2024
1 parent 83e998d commit f624d77
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions js/photons/model/PhotonsExperimentSceneModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ export default class PhotonsExperimentSceneModel {
assert && assert( interaction.reflectionInfo, 'reflection info missing' );

// This photon state was reflected. First step it to the reflection point.
const dtToReflection = photonState.position.distance( interaction.reflectionInfo!.reflectionPoint ) / PHOTON_SPEED;
assert && assert( dtToReflection <= dt );
photonState.step( dtToReflection );
const dtToReflectionPoint =
photonState.position.distance( interaction.reflectionInfo!.reflectionPoint ) / PHOTON_SPEED;
assert && assert( dtToReflectionPoint <= dt );
photonState.step( dtToReflectionPoint );

// Change the direction of the photon to the reflection direction.
photonState.direction = interaction.reflectionInfo!.reflectionDirection;

// Step the photon the remaining time.
photonState.step( dt - dtToReflection );
photonState.step( dt - dtToReflectionPoint );

interactionCount++;
}
Expand All @@ -247,9 +248,9 @@ export default class PhotonsExperimentSceneModel {
assert && assert( interaction.splitInfo, 'split info missing' );

// The resulting interaction was a split of the photon state. First step the state to the split point.
const dtToReflection = photonState.position.distance( interaction.splitInfo!.splitPoint ) / PHOTON_SPEED;
assert && assert( dtToReflection <= dt );
photonState.step( dtToReflection );
const dtToSplitPoint = photonState.position.distance( interaction.splitInfo!.splitPoint ) / PHOTON_SPEED;
assert && assert( dtToSplitPoint <= dt );
photonState.step( dtToSplitPoint );

// Update the state based on the first split info element.
photonState.direction = interaction.splitInfo!.splitStates[ 0 ].direction;
Expand Down

0 comments on commit f624d77

Please sign in to comment.