Skip to content

Commit

Permalink
Bug with radian clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
ftripier committed Sep 3, 2018
1 parent 4a490cd commit e661227
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function correctEnergy(state: State) {
const energySign = energyDifference > 0 ? -1 : 1;
const velocitySign = state.system.angularVelocity > 0 ? 1 : -1;
state.system.angularVelocity += energySign * velocitySign * adjustment;
const newEnergy = getCurrentEnergy(state);
}
}

Expand All @@ -143,7 +144,7 @@ function evolveSystem(state: State, dt: number) {
if (Math.abs(state.system.theta) > Math.PI * 2) {
const sign = state.system.theta > 0 ? -1 : 1;
state.system.theta +=
sign * Math.PI * 2 * Math.floor((state.system.theta / Math.PI) * 2);
sign * Math.PI * 2 * Math.floor(state.system.theta / (Math.PI * 2));
}
}

Expand Down

0 comments on commit e661227

Please sign in to comment.