Points on a Sphere and Cylinder

Started by
0 comments, last by fpsgamer 16 years, 10 months ago
Here is what I'm trying to do. I need to do collision detection in my game but I'm having trouble finding out the points to use or even how to figure where those points are. I'm using gluSolidSphere(3.0, 10, 10) for the sphere and gluSolidCylinder(.5,6,10,10) then I translate both objects away from each other. For the collision detection I was going to use basic 2D based of a cube this is why I need the points. Unless there is an easier why to do collision dectection.
Advertisement
There are a number of ways you can do this. For example if you are testing bounding box and sphere/cylinder collision you have to express the sphere and cylinder using their "implicit equations" (this is an equation of the form f(x)=0). Then you sub the corner points of the bounding box into the equations and check of the result for any of the corners is less than or equal to zero, in which case there is a collision.

Or if you want to do sphere sphere collision you simply find the distance between the center of sphere1 and sphere2, and if the distance is less than or equal radius1 + radius2 there is a collision.

Now you probably want to know how to express your spheres and cylinders using thoes equations. Well you simply find thoes implicit equations and use the properties of thoes shapes to "fill them in".

My explanation may still be too high level, so If youre still unsure just ask for clarifacation.

This topic is closed to new replies.

Advertisement