From e661227b76cd07d61cf09c6d8f0523992468be87 Mon Sep 17 00:00:00 2001 From: Felix Tripier Date: Mon, 3 Sep 2018 14:19:03 -0700 Subject: [PATCH] Bug with radian clamping --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 33651ad..3bc44f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); } } @@ -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)); } }