# How to calculate velocities after collision?

I'm currently writing a program for a particle simulator. One of the requirements is that the particles collide in a realistic way. However, I don't know how to calculate the final velocities.

For each collision, I have the $x$-component and $y$-component of each velocity, as well as the displacement and mass of each particle.

Is it possible to calculate the direction and magnitude of their velocities after the collision? If so, how?

• Start by reading about momentum conservation – Kyle Kanos Dec 21 '13 at 19:51
• I've read on it, and attempted to use both the conservation of momentum and the conservation of kinetic energy to find a nice equation, but I end up with this extremely complicated work. I was wondering if there was a better way. – Cisplatin Dec 21 '13 at 20:03
• The only better way is to make mostly unrealistic assumptions (e.g. all head on collisions). If you want realism, you need to have that messy formula. – Kyle Kanos Dec 21 '13 at 20:06
• One problem: there's a $\pm$ sign at one point: I don't know how to deal with that. – Cisplatin Dec 21 '13 at 20:10
• I do not believe there is supposed to be a $\pm$ in there, but it's possible that the sign depends on whether it is a head-on collision or not (i.e., both particles in same direction or opposite directions). – Kyle Kanos Dec 21 '13 at 20:25

2 dimensional collision can be reduced to a 1-dimensional problem in the case of spheres--see here. The $\pm$ you encounter when solving the kinetic energy is likely because there are two solutions and the equations are satisfied by either one. One solution is simply where the particles pass right through eachother, which you can discard.

• Those equations were just what I was looking for - thanks! – Cisplatin Dec 22 '13 at 2:04
• Minor comment to the post (v1): Please consider to mention explicitly author, title, etc. of link, so it is possible to reconstruct link in case of link rot. – Qmechanic Dec 22 '13 at 7:46

Note: The simplest method of calculating collisions use some method of applying impulses to objects that collide at some point in time. The simplest algorithm is to test if two objects are intersecting at some point in time, and if they are you fix it so that they stop intersecting each other, and then apply the calculated impulses on each object. However, this isn't completely correct. You really need to find out which collisions happened first, step the whole simulation back to the moment of the first collision, and calculate the new velocities right then. This works correctly if you have many momentary and interdependent collisions.

In the worst case, if the particles are dense and come into contact with each other, the easiest method I've found (which is used in this simulation and which I used to handle collision in this simulation) is to use forces instead of impulses. Again you reduce it to a 1-dimensional problem, and have the force of interaction between two particles be:

$$f=-k d-\mu v$$

where $\mu$ and $k$ are constants, $-k d$ is a Hookean spring repulsive force, $v$ is the relative velocity of the two particles along their axis of collision, and $-\mu v$ is a viscous friction force.

I believe that if you want more accurate contact physics (with accurate sliding point contacts instead of a spring force) you'll have to use a much more sophisticated method.