I initially coded my simulation using the standard equations of motions, but as is known, it ended up being quite unstable, even if it technically worked.

If we take x(t) to be the position-function of the equations of motion, I calculated my "next" position in the simulation by re-factoring x(t+delta), as follows:

x(t+delta) = x(t) + (1/2)*a*delta^2 + a*t*delta
t = t + delta

Most importantly, a is calculated as NetForce/Mass. If my system/particle encounters a collision, a normal force influences the net force in such a way that it is 0 on the axis of the collision (ie if it falls on the ground, force of gravity is pulling down, normal force of floor cancels gravity). So far, this has worked splendidly with any kind of collision.

However, I decided to switch to Verlet integration as it is known to be more stable, and for some reason, it completely ignores collision. I use the following formulas:

x(t+delta) = x(t) + v(t) * delta + .5*a(t)*delta^2
v(t+delta) = v(t) + .5 * (a(t) + a(t+delta)) * delta
a(t+delta) = NetForce / Mass
t = t + delta

Where v(0)=0, a(0)=0. As such, in addition to old position, I also store old acceleration and velocity. However, I get the aforementioned problem: It just doesn't work properly, as it ignores collision. Even though it should be factored in into the acceleration already... The problem lies therein that my acceleration is 0 (obviously) in the moment of collision, but Verlet is not purely a product of acceleration. As such, it continues moving my particles even when they might have 0 acceleration at a specific moment.

How should I approach this?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.