Elastic collisions between more than two billiard balls
Moderators: gmalivuk, Moderators General, Prelates

 Posts: 6
 Joined: Thu May 01, 2008 9:45 pm UTC
Elastic collisions between more than two billiard balls
Heya all. Not entirely sure if this the right board to post this in, but my program is more mathrelated than physicsrelated, so whatever.
So I've got the classic "make a billiards ball simulation" programming assignment. Make a bunch of balls with equal mass bounce around on a frictionless table with perfectly elastic collisions, conserving momentum and kinetic energy and such. Now, the professor told us to only worry about collisions between two balls at a time, and that considering simultaneous collisions between more than two balls will "cause our brains to explode." Of course, now that he actually said that I won't be satisfied until my program does it.
Collisions between only two balls are indeed a piece of cake. Get the line between the center of the balls, get the vector projections of both ball's velocity vectors in the direction of that line, then add that to the other balls' velocity and subtract it from its own. Fairly easy. But what about for more than two balls? For instance, say you have the cue ball traveling east down the center of the Xaxis, and two other balls sitting stationary a ways away just above and just below the Xaxis. The cue ball collides with the other two balls simultaneously. Common sense tells me that the ball above the Xaxis will be knocked northeast, the ball below will be knocked southeast with a speed equal to the first, and the cue ball will be left traveling slowly but directly east or west.
But the way I have it right now, only considering a collision between two balls at at time, it seems that in this scenario whichever of the two collisions is considered first gets more kinetic energy imparted to it. For example, the bottom ball will go flying southeast, the top ball will go northwest but much slower, and the cue ball will be left going very slowly northwestish. Clearly this whole "considering only one collision at a time" thing does not produce an accurate result in this circumstance. But thinking about it, I'm not really even sure how I would calculate the vectors even if I considered all three balls together. So uh... anyone here know how to do this? Links to a site that would help me are also appreciated.
Thanks guys =)
So I've got the classic "make a billiards ball simulation" programming assignment. Make a bunch of balls with equal mass bounce around on a frictionless table with perfectly elastic collisions, conserving momentum and kinetic energy and such. Now, the professor told us to only worry about collisions between two balls at a time, and that considering simultaneous collisions between more than two balls will "cause our brains to explode." Of course, now that he actually said that I won't be satisfied until my program does it.
Collisions between only two balls are indeed a piece of cake. Get the line between the center of the balls, get the vector projections of both ball's velocity vectors in the direction of that line, then add that to the other balls' velocity and subtract it from its own. Fairly easy. But what about for more than two balls? For instance, say you have the cue ball traveling east down the center of the Xaxis, and two other balls sitting stationary a ways away just above and just below the Xaxis. The cue ball collides with the other two balls simultaneously. Common sense tells me that the ball above the Xaxis will be knocked northeast, the ball below will be knocked southeast with a speed equal to the first, and the cue ball will be left traveling slowly but directly east or west.
But the way I have it right now, only considering a collision between two balls at at time, it seems that in this scenario whichever of the two collisions is considered first gets more kinetic energy imparted to it. For example, the bottom ball will go flying southeast, the top ball will go northwest but much slower, and the cue ball will be left going very slowly northwestish. Clearly this whole "considering only one collision at a time" thing does not produce an accurate result in this circumstance. But thinking about it, I'm not really even sure how I would calculate the vectors even if I considered all three balls together. So uh... anyone here know how to do this? Links to a site that would help me are also appreciated.
Thanks guys =)
Re: Elastic collisions between more than two billiard balls
Common sense is wrong.
A 3way simultaneous collision has too many degrees of freedom. If you set up the equations, there are an infinite number of possible solutions that satisfy all possible collisions. However if you try to physically simulate the collision only 6 of those solutions will show up. Those 6 solutions correspond to the 6 different orders that the balls can collide pairwise.
In particular, no matter how hard you try, you'll never succeed in getting the obvious solution that common sense tells you has to be possible.
For a simpler version of the same indeterminism take a bouncy ball (those little superballs are perfect) and try throwing it at a 45 degree angle into the corner between a wall and a floor. No matter how hard you try, it will never come back at anything close to a 45 degree angle.
A 3way simultaneous collision has too many degrees of freedom. If you set up the equations, there are an infinite number of possible solutions that satisfy all possible collisions. However if you try to physically simulate the collision only 6 of those solutions will show up. Those 6 solutions correspond to the 6 different orders that the balls can collide pairwise.
In particular, no matter how hard you try, you'll never succeed in getting the obvious solution that common sense tells you has to be possible.
For a simpler version of the same indeterminism take a bouncy ball (those little superballs are perfect) and try throwing it at a 45 degree angle into the corner between a wall and a floor. No matter how hard you try, it will never come back at anything close to a 45 degree angle.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.

 Posts: 6
 Joined: Thu May 01, 2008 9:45 pm UTC
Re: Elastic collisions between more than two billiard balls
Well, yeah, for a superball I would assume as such. But is there really no way to simulate the mathematically precise situation that I described? The cue ball hits the two stationary balls at precisely the same time in a perfectly elastic collision, and the two stationary balls are not in contact. That seems pretty precise to me; I have a hard time believing there's no deterministic solution.
 BlackSails
 Posts: 5315
 Joined: Thu Dec 20, 2007 5:48 am UTC
Re: Elastic collisions between more than two billiard balls
ShiningMasamune wrote:Well, yeah, for a superball I would assume as such. But is there really no way to simulate the mathematically precise situation that I described? The cue ball hits the two stationary balls at precisely the same time in a perfectly elastic collision, and the two stationary balls are not in contact. That seems pretty precise to me; I have a hard time believing there's no deterministic solution.
Why not treat two balls as one ball, determine the collision between the double ball and the real ball, and then determine how to split the energy on the double ball.
Re: Elastic collisions between more than two billiard balls
ShiningMasamune wrote:Well, yeah, for a superball I would assume as such. But is there really no way to simulate the mathematically precise situation that I described? The cue ball hits the two stationary balls at precisely the same time in a perfectly elastic collision, and the two stationary balls are not in contact. That seems pretty precise to me; I have a hard time believing there's no deterministic solution.
Set up the equations for yourself. Suppose that A is traveling at speed m and hits B and C at the same time. All balls have the same mass. Afterwards B has speed m_{b} and C has speed m_{c}. Their directions of motion have to be directly away from the point of impact, so you can figure out their final momentum. From conservation of momentum you can find the final momentum of A. The expression is a little complicated  it will depend on m, m_{b}, m_{c} the direction of A's initial motion, and the angles which B and C may be found at. So we have 2 unknowns.
But we have one more equation to throw at it, energy is conserved. However 1 equation in 2 unknowns does not give us a single solution, we still have a degree of freedom left. So there are an infinite number of theoretically possible solutions. One of those solutions will be the limiting case of what happens if A hits B then C. The other will be the limiting case of what happens if A hits C then B. If you try to actually run a physical experiment, you'll never hit it exactly, so the only outcomes you'll ever observe are those two limiting cases.
Note that the significant difference with the 2 ball case is that in the 2 ball case by the time you get to the conservation of energy equation you have one equation in one unknown, which only has one solution.
BlackSails wrote:Why not treat two balls as one ball, determine the collision between the double ball and the real ball, and then determine how to split the energy on the double ball.
I guarantee you that that gives the wrong answer. The valid solutions all wind up with some of the energy of the first ball absorbed in moving the two stationary balls apart. This attempt at simplification will not allow that possibility.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
Re: Elastic collisions between more than two billiard balls
"No matter how hard you try" is an exaggeration. If you are precise enough, then the white ball will indeed hit the two balls simultaneously, and you will get a symmetric situation. The problem (I think) is that "precise enough" is "really fucking precise". I haven't actually tried it. The best way to determine how precise you need to be is to try it. If you fail every time, have a friend who is good at pool try it. If that fails every time, build a machine to try it.btilly wrote:In particular, no matter how hard you try, you'll never succeed in getting the obvious solution that common sense tells you has to be possible.
Interesting. I was going to object that it should always come out at a 45 degree angle (no matter what it hits first), but I tried it with a tennis ball. There's a lack of symmetry because each collision puts spin on the ball.btilly wrote:For a simpler version of the same indeterminism take a bouncy ball (those little superballs are perfect) and try throwing it at a 45 degree angle into the corner between a wall and a floor. No matter how hard you try, it will never come back at anything close to a 45 degree angle.
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?
 Dusty Chalk
 Posts: 142
 Joined: Thu May 01, 2008 9:00 pm UTC
Re: Elastic collisions between more than two billiard balls
I'm not sure, but unless you introduce something else besides conservation of momentum (mv_{before} == mv_{after}) and conservation of kinetic energy (mv^{2}_{before} == mv^{2}_{after}), you get a "too many variables/not enough equations" system. Which is why your head would blow up. Or perhaps you would just pout.
I remain,
:Peter, aka :Dusty :Chalk
:Peter, aka :Dusty :Chalk
Re: Elastic collisions between more than two billiard balls
antonfire wrote:"No matter how hard you try" is an exaggeration. If you are precise enough, then the white ball will indeed hit the two balls simultaneously, and you will get a symmetric situation. The problem (I think) is that "precise enough" is "really fucking precise". I haven't actually tried it. The best way to determine how precise you need to be is to try it. If you fail every time, have a friend who is good at pool try it. If that fails every time, build a machine to try it.btilly wrote:In particular, no matter how hard you try, you'll never succeed in getting the obvious solution that common sense tells you has to be possible.
If I was exaggerating, it was not by much. To get anything other than the two limiting solutions you need the second collision to start while the first two balls are still in the middle of their collision. To come up with the common sense solution you will need the collisions to start so close together that the two target balls deform in perfect unison.
I am willing to bet money that the human pool player will never succeed. I'm curious how difficult it would be to build a machine that can do it. If the balls are on a real pool table moving at normal speeds, it might be impossible. (The response of the felt on different passes will differ, limiting how precisely you can aim it.) But I wouldn't be surprised if it is doable with exactly the right equipment. However I believe it will be much harder than you'd think.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
Re: Elastic collisions between more than two billiard balls
Yes, I imagine it'd be hard for a human to do it. However, I'm not terribly sure that it's so hard to get the balls to deform enough that the cue ball is colliding with both balls simultaneously. Things deform by a surprisingly large amount in collisions.
A pool ball has a mass of about .16 kg. One such pool ball moving at 5 meters per second has a kinetic energy of about 2 J. A ball made out of phenolic resin has a Young's modulus of about 3*10^{9} N/m^{2}. Modelling a cue ball as a cube (assume a spherical cow) of side length 4 cm, it has a spring constant of k=1.2*10^8 N/m, and stores an energy of kx^{2}/2 when compressed by a length of x. So, x=sqrt(2*(2 J)/ (1.2*10^8 N/m))=.18 mm. Not a minute amount. If you're off by that .18 mm in a straight shot, the ball you hit deviates by about 4 cm after going a meter. I think pool players (especially people who do trick shots) can do better than that. Especially if the cue ball starts out pretty close. I think, at least in terms of orders of magnitude, a good pool player, given enough attempts, might be able to hit a cue ball fast enough and accurately enough that it could collide with two balls at the same time. I do think it'd be hard.
In fact, the naive two ball collision has too many variables and not enough unknowns, if all you know is the incoming velocity of the cue ball. Given more information, such as where it hits, lets you solve the problem.
In this case, let's say the cue ball of mass 1 is coming in at velocity 1 along the x axis, and collides, at the same time, with two balls, which are just touching each other. By symmetry the two balls go off at velocities +vy in the y direction, and vx in the x direction, and the cue ball goes along the x axis with velocity v. (Note that this is probably not a valid assumption, as per discussion above, so, all of the following is physically useless for predicting the behavior of actual cue balls.) Then 2vy^{2}+2vx^{2}+v^{2} = 1, and 2vx+v=1. Two equations, three unknowns. You're stuck, until you realize that you had the same problem when you were solving the twoball problem. Also, you still haven't used the fact that the balls are just touching. Well, which direction does each of the two balls go in? Just as in the two ball case, each is struck by the cue ball in a particular direction, and that's the way that the impulse is transferred. (Note that they don't interact with each other.) So, we know that vy=vx*sqrt(3)/3. Using this additional equation, we get that vx=3/5, vy=sqrt(3)/5, v=1/5. If they were spaced a distance of 2(sqrt(2)1)r, rather than touching, you'd get different solutions, they'd go off at 60 degree angles, and the cue ball would end up not moving.
A pool ball has a mass of about .16 kg. One such pool ball moving at 5 meters per second has a kinetic energy of about 2 J. A ball made out of phenolic resin has a Young's modulus of about 3*10^{9} N/m^{2}. Modelling a cue ball as a cube (assume a spherical cow) of side length 4 cm, it has a spring constant of k=1.2*10^8 N/m, and stores an energy of kx^{2}/2 when compressed by a length of x. So, x=sqrt(2*(2 J)/ (1.2*10^8 N/m))=.18 mm. Not a minute amount. If you're off by that .18 mm in a straight shot, the ball you hit deviates by about 4 cm after going a meter. I think pool players (especially people who do trick shots) can do better than that. Especially if the cue ball starts out pretty close. I think, at least in terms of orders of magnitude, a good pool player, given enough attempts, might be able to hit a cue ball fast enough and accurately enough that it could collide with two balls at the same time. I do think it'd be hard.
Too many variables and not enough equations happens a lot, and such problems aren't unsolvable. You just need more information.Dusty Chalk wrote:I'm not sure, but unless you introduce something else besides conservation of momentum (mvbefore == mvafter) and conservation of kinetic energy (mv2before == mv2after), you get a "too many variables/not enough equations" system. Which is why your head would blow up. Or perhaps you would just pout.
In fact, the naive two ball collision has too many variables and not enough unknowns, if all you know is the incoming velocity of the cue ball. Given more information, such as where it hits, lets you solve the problem.
In this case, let's say the cue ball of mass 1 is coming in at velocity 1 along the x axis, and collides, at the same time, with two balls, which are just touching each other. By symmetry the two balls go off at velocities +vy in the y direction, and vx in the x direction, and the cue ball goes along the x axis with velocity v. (Note that this is probably not a valid assumption, as per discussion above, so, all of the following is physically useless for predicting the behavior of actual cue balls.) Then 2vy^{2}+2vx^{2}+v^{2} = 1, and 2vx+v=1. Two equations, three unknowns. You're stuck, until you realize that you had the same problem when you were solving the twoball problem. Also, you still haven't used the fact that the balls are just touching. Well, which direction does each of the two balls go in? Just as in the two ball case, each is struck by the cue ball in a particular direction, and that's the way that the impulse is transferred. (Note that they don't interact with each other.) So, we know that vy=vx*sqrt(3)/3. Using this additional equation, we get that vx=3/5, vy=sqrt(3)/5, v=1/5. If they were spaced a distance of 2(sqrt(2)1)r, rather than touching, you'd get different solutions, they'd go off at 60 degree angles, and the cue ball would end up not moving.
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?
 Dusty Chalk
 Posts: 142
 Joined: Thu May 01, 2008 9:00 pm UTC
Re: Elastic collisions between more than two billiard balls
Isn't that the same as adding another equation?antonfire wrote:Too many variables and not enough equations happens a lot, and such problems aren't unsolvable. You just need more information.Dusty Chalk wrote:I'm not sure, but unless you introduce something else besides conservation of momentum (mvbefore == mvafter) and conservation of kinetic energy (mv2before == mv2after), you get a "too many variables/not enough equations" system. Which is why your head would blow up. Or perhaps you would just pout.
Also: that's why I qualified my statement with "unless you introduce something else".
Finally: nice work!
I remain,
:Peter, aka :Dusty :Chalk
:Peter, aka :Dusty :Chalk
Re: Elastic collisions between more than two billiard balls
antonfire wrote:Yes, I imagine it'd be hard for a human to do it. However, I'm not terribly sure that it's so hard to get the balls to deform enough that the cue ball is colliding with both balls simultaneously. Things deform by a surprisingly large amount in collisions.
A pool ball has a mass of about .16 kg. One such pool ball moving at 5 meters per second has a kinetic energy of about 2 J. A ball made out of phenolic resin has a Young's modulus of about 3*10^{9} N/m^{2}. Modelling a cue ball as a cube (assume a spherical cow) of side length 4 cm, it has a spring constant of k=1.2*10^8 N/m, and stores an energy of kx^{2}/2 when compressed by a length of x. So, x=sqrt(2*(2 J)/ (1.2*10^8 N/m))=.18 mm. Not a minute amount. If you're off by that .18 mm in a straight shot, the ball you hit deviates by about 4 cm after going a meter. I think pool players (especially people who do trick shots) can do better than that. Especially if the cue ball starts out pretty close. I think, at least in terms of orders of magnitude, a good pool player, given enough attempts, might be able to hit a cue ball fast enough and accurately enough that it could collide with two balls at the same time. I do think it'd be hard.
Wow, you're right that it is easier than I thought it would be.
However I submit that it would be harder than you're making it out to be. First of all your calculation is heavily speed dependent. If the balls are going twice as fast, there will be 4 times the energy and twice the deformation. If the balls are going half as fast, there will be half the deformation. I suspect that 5 m/s is on the fast side, which would make the deformation less. Furthermore there is the issue that you're hitting 2 balls at once. You don't transfer all of the energy to those balls, and therefore the deformation is less. When you put it together, I suspect the true deformation you have to work with is about 0.1 mm or less.
But remember that this is the deformation needed to get something other than the two obvious limiting cases. To get something close to the naive common sense solution, you're going to have to make sure that the energy is being transferred at the same time. Else the collision with one ball will change the other collision. "At the same time" is relative. But given how far apart the two natural limiting solutions are, I wouldn't be surprised if you'd have to hit within 0.01 mm or less of perfect to get something that looks like the common sense solution. That's a fraction of the width of the average human hair.
I'll believe that a good human can get something other than the obvious limits. I'd still want a machine to get it to look like the common sense solution.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.

 Posts: 6
 Joined: Thu May 01, 2008 9:45 pm UTC
Re: Elastic collisions between more than two billiard balls
Wow, I have to say, this is the most awesome forum ever. I never though this thread would generate a conversation this interesting =)
Antonfire, that was some massively impressive mathfu on display there. Awesome as this is, it looks like this would be more trouble than it's worth to actually program, especially since the only way it would ever happen is if I explicitly set it up to. It's still a fascinating problem though. The result of a simultaneous collision is so much different from that of a firstthisonethentheotherone collision, even though they differ by only milliseconds. You'd expect a smoother curve... Wish I had a pool table to test on, I want to give it a try myself!
Antonfire, that was some massively impressive mathfu on display there. Awesome as this is, it looks like this would be more trouble than it's worth to actually program, especially since the only way it would ever happen is if I explicitly set it up to. It's still a fascinating problem though. The result of a simultaneous collision is so much different from that of a firstthisonethentheotherone collision, even though they differ by only milliseconds. You'd expect a smoother curve... Wish I had a pool table to test on, I want to give it a try myself!
 Dusty Chalk
 Posts: 142
 Joined: Thu May 01, 2008 9:00 pm UTC
Re: Elastic collisions between more than two billiard balls
Unless you reprogrammed it on a PS3 cluster.ShiningMasamune wrote:Awesome as this is, it looks like this would be more trouble than it's worth to actually program...
So what do you do if you get a simultaneous collision? Do you just delay one of them by a single computer cycle, so that they're not simultaneous, arbitrarily separating them into two distinct collisions?
And why do you guys keep using the word "naive", don't you mean "trivial"?
I remain,
:Peter, aka :Dusty :Chalk
:Peter, aka :Dusty :Chalk
 UserGoogol
 Posts: 90
 Joined: Mon Jan 29, 2007 5:58 am UTC
Re: Elastic collisions between more than two billiard balls
It occurs to me (especially if you're writing a computer program and don't have to deal with solving the differential equations this would involve) that you could just solve the problem in term of forces rather than energy and momentum. When two balls are close enough that they're touching, the force some function of the distance between the points in the opposite direction as the difference between the balls. (I imagine that from Hooke's law you get something like F = {if d < 2r : k(d  2r), else: 0} where r is the radius of the balls, d is the distance between the centers and k is the "spring constant" of the ball, but I greatly suspect this isn't particularly right.) Since you're writing a computer program anyway, all you'd need to do would be to accelerate each ball by the appropriate amount in each step. I suspect complications would arise, but in principle this would give you results.
Re: Elastic collisions between more than two billiard balls
By "naive", I think both of us meant "ignoring some relevant information", or "natural first thing to try", which isn't the same as "trivial".Dusty Chalk wrote:And why do you guys keep using the word "naive", don't you mean "trivial"?
And yes, actually coding the sort of thing in would be ridiculously annoying, and certainly not worth the effort. I just wanted to point out that the fact that at first glance there are more equations than unknowns doesn't actually stop you from solving the problem in certain cases. (Though in the general case where each ball is interacting with both others at the same time, I think you actually have to start using elasticity and the like.)
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?
Re: Elastic collisions between more than two billiard balls
Thinking further about antonfire's calculations, while producing "can't be the result of pairwise collisions" is hard with 3 balls, I think it is easy with 4. Just have 3 balls touching, then hit them with a 4th.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
Re: Elastic collisions between more than two billiard balls
Or, say, 15 arranged in a triangle, then hit them with a 16th.
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?
 Dusty Chalk
 Posts: 142
 Joined: Thu May 01, 2008 9:00 pm UTC
Re: Elastic collisions between more than two billiard balls
I think my brain just imploded.antonfire wrote:Or, say, 15 arranged in a triangle, then hit them with a 16th.
I remain,
:Peter, aka :Dusty :Chalk
:Peter, aka :Dusty :Chalk
Re: Elastic collisions between more than two billiard balls
antonfire wrote:Or, say, 15 arranged in a triangle, then hit them with a 16th.
I thought about that. But the problem is that the number of possible outcomes from 2ball collisions in that case is so large that it is hard to verify that the outcome is something different.
In the 4ball case you can arrange that there are 3 impacts, and you can show that the result was not possible from a series of 2ball impacts.
Some of us exist to find out what can and can't be done.
Others exist to hold the beer.
Re: Elastic collisions between more than two billiard balls
I messed around with some tennis balls (didn't feel like going over to a pool table at this hour), and yup, the qualitative results are pretty different depending on whether there's a bit of space between the three balls which are initially at rest or not. If you're going to try this, keep in mind that it's better to make them into a "fork" with a right angle (or wider) rather than a triangle, since in a triangle the ball that's hit first tries to go back after the collision, so whatever you hit it with ends up interfering.
Jerry Bona wrote:The Axiom of Choice is obviously true; the Well Ordering Principle is obviously false; and who can tell about Zorn's Lemma?
Re: Elastic collisions between more than two billiard balls
UserGoogol wrote:It occurs to me (especially if you're writing a computer program and don't have to deal with solving the differential equations this would involve) that you could just solve the problem in term of forces rather than energy and momentum. When two balls are close enough that they're touching, the force some function of the distance between the points in the opposite direction as the difference between the balls. (I imagine that from Hooke's law you get something like F = {if d < 2r : k(d  2r), else: 0} where r is the radius of the balls, d is the distance between the centers and k is the "spring constant" of the ball, but I greatly suspect this isn't particularly right.) Since you're writing a computer program anyway, all you'd need to do would be to accelerate each ball by the appropriate amount in each step. I suspect complications would arise, but in principle this would give you results.
This is pretty much how I'd do it. Basically you pretend it's a molecular dynamics simulation. If you do have a smaller enough timestep and a good iteration scheme, it'll conserve momentum and energy pretty well. ("Pretty well" in numerical simulations means ~1%)
Who is online
Users browsing this forum: No registered users and 10 guests