Skip to content

Commit 0f423b4

Browse files
committed
verlet integrator now respects node mass
1 parent 8355d4d commit 0f423b4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/physics/physics.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
if (that.integrator=='euler'){
294294
point.v = point.v.add(point.f.multiply(timestep)).multiply(1-that.friction);
295295
}else{
296-
point.v = point.v.add(point.f.add(point._F).multiply(timestep*0.5)).multiply(1-that.friction);
296+
point.v = point.v.add(point.f.add(point._F.divide(point._m)).multiply(timestep*0.5)).multiply(1-that.friction);
297297
}
298298
point.f.x = point.f.y = 0
299299

@@ -323,8 +323,8 @@
323323
}else{
324324
//this should follow the equation
325325
//x(t+1) = x(t) + v(t) * timestep + 1/2 * timestep^2 * a(t)
326-
var accelPart = point.f.multiply(0.5 * timestep * timestep);
327-
point.p = point.p.add(point.v.multiply(timestep)).add(accelPart);
326+
var accel = point.f.multiply(0.5 * timestep * timestep).divide(point.m);
327+
point.p = point.p.add(point.v.multiply(timestep)).add(accel);
328328
}
329329

330330
if (!bottomright){

0 commit comments

Comments
 (0)