Jump to content
  • Advertisement
Sign in to follow this  
Toolmaker

Sphere - Polygon collision detection?

This topic is 3760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!