Skip to content

Commit

Permalink
More technically correct comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ftripier committed Sep 1, 2018
1 parent 9cd8795 commit f798e62
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ function update(state: State) {
let newAngularVelocity =
oldAngularVelocity + gravitationalAcceleration * normalizedDt;

// because of floating point error, the energy of the system rises over time.
// this hopefully to corrects that over time.
// because of floating point error and because we don't evolve the system at fixed timesteps,
// the energy of the system rises over time.
// This corrects for these errors.
const potentialEnergy = (gravity: number, mass: number, theta: number) =>
-gravity * mass * Math.cos(theta);
const kineticEnergy = (mass: number, angularVelocity: number) =>
Expand Down

0 comments on commit f798e62

Please sign in to comment.