# Simple 2D ball collision help

Dude J McCool
This is a little "high school", i know, but I'm trying to design a simple collision detection program and i need a few formulas, but i can't find them anywhere.

Here is the problem. I have two balls of equal size and mass in a frictionless, 2D environment. These balls have known velocities (x,y), radii and mass. The balls collide at a given point. An angle can be determined by drawing a line between the centers of each ball, and determining the angle of that line with respect to the x-axis. Knowing all of these, how can i now go about determining the velocities after the collision? and thus, the angle of deflection?

I'm looking for something like:
Ball1 Vx, Vy After collision
Ball2 Vx, Vy After collision.

-benny

Homework Helper
A few clarifications:

Is this for "real world" analysis? That is, will the balls be able to spin? Or will they be without significant rotation. And will the collision be perfectly elastic, or will there be some less-than-perfect collisions?

"Ideal world" calculations are a lot easier.

Dude J McCool
Arg! I forgot to say this. Stupid me. Yeah, totally elastic. This is an 'ideal' situation.

-benny

StephenPrivitera
Hi benny,
I was working with this exact problem a while back. Apparently, the impulse between the two masses act along the line joining the centers of mass. If the interaction is over a very short period of time, you can regard this impulse as constant in direction. Knowing this, you can resolve the velocity vectors into components that are perpendicular and parallel to the line of action of the force. Then, you can treat the parallel components as a 1D collision. The perpendicular component is unaffected because acceleleration must be parallel to the force. Simply add the results together to get your final velocities.

Homework Helper
The short answer to this problem is in the phenomenon of "velocity exchange." IF two particles that have identical mass collide ina perfectly elastic collision, they will each have a final velocity that is identical to the initial velocity of the other.

This of course never happens perfectly in the real world. In a sample of low-pressure helium, you would get the closest possible approximation of this ideal situation.

THe math is a bit harder. YOu have to simultaneously consider the conservation of momentum in the "x" direction, the conservation of momentum in the "y" direction, and the conservation of kinetic energy (which is independant of direction).

You get three formulas, and since M is constant, it keeps cancelling out. (note the " ' " means "after the collision)

v1x + v2x = v1x' + v2x' (v1x +v2x is a known quantity, call it "A")

v1y + v2y = v1y' + v2y' (v1y + v2y is "B")

conservation of KE brings this formula:
(v1x)^2 + (v1y)^2 + (v2x)^2 + (v2y)^2 [call this "C"]
= (v1x')^2 + (v1y')^2 + (v2x')^2 + (v2y')^2

You need at least one more formula (since there are four unknowns)

EDIT: I just noticed that my forth formula is not correct (I took it out) can someone else take it from here? I got to go teach a class.

Last edited:
Homework Helper
OK, I'm back, but I'm still blanking on the last part of this problem. THere is a trick to do here and I've forgotten what it is! Hopefully someone else will be slong soon...

Dude J McCool
perhaps http://www.phy.ntnu.edu.tw/java/collision2D/collision2D.html will help those who are almost on the right track.

It would seem to me that the equation would be something like this:

V2' = sqrt((cos &theta; * V2)^2 + (sin &beta; * V1)^2))
V1' = sqrt((cos &theta; * V1)^2 + (sin &beta; * V2)^2))

Where:
&theta; is the angle between the force vector of ball1 and the V1 direction vector, and
&beta; is the angle between the force vector of ball2 and the V2 direction vector.

I think this is right if masses are equal, if not then you just multiply the vectors by the mass. Now, the problem is, on a coordinate x,y 2D plane, where right movement is + left -, up + and down -, how can sign be preserved with all the exponents happening? That is, if the equation is right in the first place.

-benny

Last edited by a moderator:
Dude J McCool
I don't mean to sound like I'm egging you guys on, but i find it odd that questions involving much more complex and abstract physical theories are being answered, yet what would seem to me like a fairly simple problem, is causing so much trouble...or apathy, as the case very well may be.

Stranger still is that i can't find one piece of source code in any language that provides proper 2D elastic ball collisions. Like i said, i find numberous java applets, like the one above, so the source must exist, but there is no code. I would think that any programmer working on any kind of physics system in their code, or collision system, would construct this very system as a FIRST step, i mean, i would. So why then is code so difficult to find? and why are the formulas not more publisized when ball physics seems quite popular?

The situation is very confusing to me, but not quite as confusing as trying to derive the solution . I need this by tomorrow, so any help, would be VERY much appreciated.

-benny