Browse files

verlet integrator now respects node mass

  • Loading branch information...
1 parent 8355d4d commit 0f423b48a335d0a000c1c1f69b3a266c6447fb52 @samizdatco committed May 27, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/physics/physics.js
View
6 src/physics/physics.js
@@ -293,7 +293,7 @@
if (that.integrator=='euler'){
point.v = point.v.add(point.f.multiply(timestep)).multiply(1-that.friction);
}else{
- point.v = point.v.add(point.f.add(point._F).multiply(timestep*0.5)).multiply(1-that.friction);
+ point.v = point.v.add(point.f.add(point._F.divide(point._m)).multiply(timestep*0.5)).multiply(1-that.friction);
}
point.f.x = point.f.y = 0
@@ -323,8 +323,8 @@
}else{
//this should follow the equation
//x(t+1) = x(t) + v(t) * timestep + 1/2 * timestep^2 * a(t)
- var accelPart = point.f.multiply(0.5 * timestep * timestep);
- point.p = point.p.add(point.v.multiply(timestep)).add(accelPart);
+ var accel = point.f.multiply(0.5 * timestep * timestep).divide(point.m);
+ point.p = point.p.add(point.v.multiply(timestep)).add(accel);
}
if (!bottomright){

0 comments on commit 0f423b4

Please sign in to comment.