Sphere - Polygon collision detection?

Started by
1 comment, last by Toolmaker 15 years, 10 months ago
I'm currently looking for a way to check for a collision between a sphere(Defined by it's position, movement direction and diameter) and a 4-sided polygon. I tried some googling around, but most of the information I've found confuses me. I'm looking for a simple / basic explanation on how to apply the correct math to find out if sphere is colliding with the plane(And if not, how much the distance between the sphere / polygon is). Not necessarily code that does it for me, but an explanation in simple English which explains me why/how. Sure, example (pseudo)-code is ok with me as it illustrates things. Toolmaker

Advertisement
Quote:Original post by Toolmaker
I'm currently looking for a way to check for a collision between a sphere(Defined by it's position, movement direction and diameter) and a 4-sided polygon.

I tried some googling around, but most of the information I've found confuses me. I'm looking for a simple / basic explanation on how to apply the correct math to find out if sphere is colliding with the plane(And if not, how much the distance between the sphere / polygon is).

Not necessarily code that does it for me, but an explanation in simple English which explains me why/how. Sure, example (pseudo)-code is ok with me as it illustrates things.

Toolmaker


No matter how you do it, its going to be complex. I've done it by just siting down and figuring it out but I'm not saying my method is the best or even close.

1. You need to project a vector which is the center of your sphere onto the plan of the triangle using the dot product of that triangle's normal.

2. Then you create three more normals using the direction in which one of the vectors that make up the triangle are to another one of the vectors.

3. Use the cross product of the normals form step 2 and the normal of the triangle to create three more normals that will make up the edges of your triangle.

4. You create three more vectors and project the vector from step 1 on to the three normals from step 3

5. Now you have to create three normals that are pointing from the vectors in step 4 to the vector from step 1

6. Make 3 more normals and take the vectors that make up your polygon and get the direction from that to the vector in step 4. If this normal is pointing out then return the point from the triangle and if not return step 4

7. After that you check if one of the normals are pointing in the direction of one of your edges and you return the vector for that edge from step 6. If they are not pointing in the direction then return the vector from step 1.

8. Now from the point that is returned you can get the distance from the triangle to your sphere.
This is your life, and it's ending one minute at a time. - Fight club
Ok, you lost me by at 2... Wht do you mean create 3 more normals in the direction of the triangle? Are these line normals from v0 -> v1, v1 -> v2, v2 -> v0?

Toolmaker

This topic is closed to new replies.

Advertisement