The time step dt is the same during the simulation.

However, collision often occurred in between time steps (between time t to t+dt).

We tried to detect if two object overlap each to know collision should have occurred.

Then, we need to find the exact time when collision occurred.

If this 2D collision, we use an approximation method to find the time when collision occurred.

Support the radius of two particles are r1 and r2, and the distance between two center is d.

And the relative velocity along two center is vp,

then we move back time step ddt=(d-(r1+r2))/vp to find the time collision occurred.

(The above approximation is only good if the relative velocity is small enough, i.e. vp*dt<

After we take care of collision, we need to move time forward ddt again.

[/quote]

This is a computational logic that i only appreciated and understood after using Ejs to make simulations, because i was trying to do the same thing. "detect if two object overlap each to know collision should have occurred."

In Ejs i think it is called Event Handlers.

Thanks!

it is good explanation.