#### Archived

This topic is now archived and is closed to further replies.

# Bounding Spheres

## Recommended Posts

Hi, can anyone tell me a formula to work out the reflection vector of bounding spheres? i have an array of spheres moving within a cube, i''d like to be able to make them bounce off each other at the correct angle. each sphere has a vector to store its direction, and a float to store its velocity. many thanks Dan

##### Share on other sites
The direction is a vector between the centres of the spheres.

To find the actual point of collision you can simply scale that vector by the radius of one sphere and add it to the sphere''s position vector (just be careful which sphere you use as the direction''s initial point and which as the terminal point).

##### Share on other sites
actually, the equation is very simple for a perfectly elastic collision (like 2 really really really super boncey balls smacking into each other, rather than an inelastic collision like 2 cars, 2 football players, 2 wads of grape jelly, etc...)

anyway, each sphere will have a velocity x,y,z

(as long as both spheres are of equal mass)
sphere1 = x1,y1,z1
sphere2 = x2,y2,z2

after collision:
sphere1 = x2,y2,z2
sphere2 = x1,y1,z1

that looks silly, but they really do just take each others velocity. i have to run back to work, but if you want a less elastic collision (perfectly elastic collisions don''t occur in the real world) or formulas for 2 objects of different mass post again, i am sure anyone with a college pissics book on their shelf can look up the formulas for you.

Brett Lynnes
cheez_keeper@hotmail.com

##### Share on other sites
quote:

after collision:
sphere1 = x2,y2,z2
sphere2 = x1,y1,z1

thats only correct if the collision is head on, if it''s off center, it gets more complicated.

NeHe has a great example on how to calculate the resulting velocities (at nehe.gamedev.net). I think it''s tutorial #31.

Watch out for advice from the successfull, they don''t want company

• ### Forum Statistics

• Total Topics
628333
• Total Posts
2982133

• 24
• 9
• 9
• 13
• 11