Skip to main content
GameDev.net gamedev.net
🔒 Locked

simultaneous sphere collisions

Started by gspdriver Apr 8, 2004 at 8:13 AM 3 replies 650+ views
Original Post
gspdriver
gspdriver
I am looking for some algorithm or physics article that can handle simultaneous collisions. Collisions of 2 spheres is ok to handle, but after 2 it gets complicating. If anybody has any resources, that would be appreciated. BTW this is for a pool game I am creating.
RowanPD
RowanPD
Nah, sounds easy.

Just think of those little stands that have those little silver balls on strings where you swing out the ball on the right and let it go. It swings back to hit the others that are all in line and the ball on the left swings out. Click, click, click ...

Taking that idea just think of one of those with 3 balls. Pull out the left and right balls to the same distance and let them go at the same time. They hit the centre ball with the same force in opposite directions. What happens ? Both balls just swing back out again and the middle ball goes nowhere.

Why ?

The middle ball receives a force from the left ball that is perfectly negated by the force from the right ball. It doesn''t matter which order you calculate the input forces just so long as you calculate all of them. The order is not important if they are simultaneous . Addition is cummutative.

So you just have you simple collision detection (which is easy for spheres). Then you just recalc the direction vectors. Repeat for all balls. 10 balls means 9+8+7+6+5+4+3+2+1=45 tests (we are remembering not to repeat tests between the same balls).

Of course, there are the walls and pockets to figure out as well. I cant help you there.

R

--------------------------------------------------------------------------
There is no point in flaming if you''ve merely poured fuel on your own head
R--------------------------------------------------------------------------There is no point in flaming if you've merely poured fuel on your own head
gspdriver
gspdriver
That''s true. If I look at the spheres with the same velocity and distance and angle, then it would be like the silver balls.

But I dont know if that same idea holds for balls with varying velocities, angles, and distances.

If the cue ball strikes 2 balls at the same time, and it strikes one of them at 50 degrees to the left and the other at 33 degrees to the right, then it becomes hairy...i think. Some people said to do it as 2 quick collisions. Then the problem is each ball is gonna get the full blunt of the cue ball''s force. This shouldnt be the case because the original force should be dispersed into the 2 other balls.

Calculating the force that would be given to the other 2 balls is ok because it''s just gonna be scaled. I think the harder part is calculating the cue balls velocity after the collision.

drreagan
drreagan
take a look at this:
http://www.gamasutra.com/features/20020118/vandenhuevel_01.htm

-------------------------------------------------------
A headache, ancillary; an hourglass auxiliary.

"something witty, blah, blah, blah"
--That One Witty Guy (remember? that one dude?)

(author of DustBot)



[edited by - drreagan on April 8, 2004 9:11:38 PM]
------------------------------------------------------- A headache, ancillary; an hourglass auxiliary."something witty, blah, blah, blah" --That One Witty Guy (remember? that one dude?)(author of DustBot)
RowanPD
RowanPD
I haven''t read the other article given by Dr Reagan but going back to the silver balls the left and right ball have different velocities as they are going in different directions. So it''ll hold.

Your point about hitting a ball that is already touching another ball is a good one. A perfect example is the break.

Maybe you''d need to calculate your two new velocities and then recursively apply a "collision" between the balls that are touching (being careful not to recalculate the same collision twice).

As for proportionately dividing the effect on a simultaneous hit then you''d need to apportion it using the angle of collision or something like that. Something the square of the cosine of the angle between the velocity and the line joining the centres of the two balls. That way hitting two balls simultaneously at 45 degrees each would give half of the force to each. Hitting one ball perfectly square on gives all it''s force. Remember that being "perfectly square on" would be reasonably rare.

Going back again to the silver balls this would be the square of the cosine of 0 degrees which is 1. Thus both left and right balls give maximum input to the middle ball but just happen to each other cancel out. The nett effect is that the right ball gives it''s velocity to the left ball and vice-versa and both balls bounce out by the input velocities of the opposite ball - minus friction, air resistance, noise dissipation etc.

Just a brain dump - I''m not sure I''m even close to being right.

R

--------------------------------------------------------------------------
There is no point in flaming if you''ve merely poured fuel on your own head
R--------------------------------------------------------------------------There is no point in flaming if you've merely poured fuel on your own head

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.