Advertisement

Simultaneous collision of spheres

Started by December 09, 2003 05:34 PM
15 comments, last by Roming22 21 years, 2 months ago
Hi, I''m currently programming a pool game, and I have trouble with simultaneous collision of balls. Here''s the trouble: Let''s say I have the some balls ready for a break shot like the ascii art shows below.

   1


  2 3
 4 5 6

I send 1 straight forward, and it hits 2 and 3 at the same time. I have no trouble finding that it hits 2 and 3, but I don''t know how to calculate the right collision response. I tried to do it by calculating the collision response of 1 and 2 , and then of 1 and 3, but it''s not right. I calculate collision response by exchanging the speeds of the balls along the vector that links the two centers. Anyone could give me a hint? Thanks, Roming22
i have never implemented col det in my programs yet but i would use just simple physics. calculate the energy and forces in ball 1. then when it collides with another ball perform the right formula for translating the forces then add it to the new ball. when you are done with that cycle through the rest of the balls.
Advertisement
Are you looking for the speedth vector for each ball ? Directions can found by taking the ball''s center. For the speedth, if you want the whole scene to look realistic, you should care of the "ball effect" (self rotation), and I''m sure you didnt thought to that, did you ?

If you dont want to care of this, theorically all the balls should have the same speedth, (beore collision has speed v, after collision, all the ball have speed v/3), only the directions change, but I''m pretty sure it will appear strange to you.

Energy formulas mentionned by adam17 can be simplified a lot when you consider that all the balls have the same weight.
As for the effects, I coded them. Acceleration, deceleration, pivoting, ...

The trouble is that I don''t know how to code a rebound function that would work when a ball is colliding 2 others at the exact same time (it happens at the break).

Theorically, the ball 2 and 3 should have the same speed (in intensity, not in direction). Ball 1 should go backward (or stop?).

What the energy formulas that adam17 is talking about?
I''m very interested, could you write them to me please?

Thanks,

Roming22
I detect for the first collision, advance the billards up to that point in time, then apply the collision. Repeat until no collisions occur or the elapsed time in the game tick is consumed.

If two collisions happen at the same time, just pick one to apply. The next iteration will detect the other collision at time 0, and you shouldn't get a result that would have interfered with the first collision you handled (if we are talking about perfect physics collisions here with no english, spinning and whatnot)

EDIT: Small grammatical and explanation error

[edited by - Waverider on December 11, 2003 2:19:06 AM]
It's not what you're taught, it's what you learn.
http://www.euclideanspace.com/physics/dynamics/collision/twod/

start with the first problems if you are not too familiar with physics. TRUST ME
Advertisement
To Waverider: that does not work in theory. The result of a ball colliding two other at the exact same time is not the result of the ball colliding a ball and then a second one. That's how I used to do it, but it's false. I can prove it.

When a ball hits a still ball, the two ball have perpendicular speed vectors after the collision. So if I handle the collision between 1 and 2 last, 1 will have a speed vector perpendicular to 1-2, and if I handle the collision between 1 and 3 last, 1 will have a speed vector perpendicular to 1-3. As 1-2 and 1-3 are not colinear, the result is not the same, therefore it's false. BTW, if I try to "average" both collision responses, there's no more conservation of energy.

To Adam17: I'll take a look, thanks.

[edited by - Roming22 on December 11, 2003 8:15:17 AM]
I look at the page adam17 gave me. I coded it in the game, and I still have the same problem. It works when it''s a collision between 2 balls, but not when 1 ball collides 2 others at a the same time.

Thanks to anybody trying to help me,

Roming22
Energy equations can be resumed, taking each ball has same weight, by :
The equation to deal with concerns cynetic equation keeping (not sur of the terms ; conservation énergie cynétique in french). That means that the sum of speeds before collision = sum of speeds after collision.
In your case, all the balls should go the same direction that ball 1 (different angle for balls 2 & 3) with speeds divided by 3 for all (length of vector), as long as my memory is ok .
Another point of view : sum of speed vector before collision = sum of speed vector after.

this only applies for balls without self-rotation, that might be your case if you''re dealing with the breaking.
If you want to deal self-rotations, you should consider that sum of rotations should also be keeped, but I dont know how to combine rotations with speeds.

This topic is closed to new replies.

Advertisement