Skip to content

Commit

Permalink
also check for 2 * Math.PI, which is necessary for negative angles, see
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Dec 6, 2024
1 parent 03e3027 commit 8256646
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/trig-tour/model/TrigTourModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ class TrigTourModel {
this._fullTurnCount = Utils.roundSymmetric( ( targetAngle - remainderAngle ) / ( 2 * Math.PI ) );
remainderAngle = targetAngle % ( Math.PI );

// If the remainderAngle is very close to Math.PI, set to 0 so that the halfTurnCount is not off by 1.
// If the remainderAngle is very close to Math.PI or 2 * Math.PI, set to 0 so that the halfTurnCount is not off by 1.
// See https://github.com/phetsims/trig-tour/issues/97.
if ( Math.abs( remainderAngle - Math.PI ) < 1e-10 ) {
if ( Math.abs( remainderAngle - Math.PI ) < 1e-10 || Math.abs( remainderAngle - 2 * Math.PI ) < 1e10 ) {
remainderAngle = 0;
}
this._halfTurnCount = Utils.roundSymmetric( ( targetAngle - remainderAngle ) / ( Math.PI ) );
Expand Down

0 comments on commit 8256646

Please sign in to comment.