Sphere-Triangle Collision

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

Recommended Posts

I dont know how long I've looking for a simple solution to a sphere-triangle collision detection, but I cant seem to find any concrete solutions to it! My situation is as follows: + I have a sphere (representing a first person shooter camera) + I have a mesh (representing a level) Collision Detection: + Check distance from the plane of nearby faces to the sphere's position + If <= Radius then make sure the sphere is within the triangle. <-- problem The data I have to use is the position of the sphere, the normal of the face plane, and the three vertices of the face itself. How can I know check to see that If the sphere where to be touching the face plane Exactly (which will mostly likely never happen) is the point in the area of the triangle? Should I go for a different approach? Should I generate a triangular prism representing the face + normal data * distance to sphere. Then check if they overlap? Any suggestions, links, or any other resources are appreciated! Thank you,

Share on other sites

Compute the minimum distance from the triangle to the center of the sphere. Mathematically, this could be a minimization double integral in barycentric coordinates. If the distance is less than r then you have a collision.

Share on other sites
Project the position (center) of the sphere along the surface normal. If the value is greater than the spheres radius, the sphere doesn't penetrate the triangle so break. Otherwise, find the image of the sphere projected on the plane and test whether that point is inside the triangle.

Share on other sites
Quote:
 test whether that point is inside the triangle.

Thats what I dont know how to do...

Share on other sites
Once you have a point in the plane of the triangle, it is easy to test whether it is inside the triangle </reassurance>. [wink] See solution 3 of this webpage.

Share on other sites
Solution 1 is the famous stencil buffer shadow technique :-)

Share on other sites
Quote:
 Original post by WhardieJonesCompute the minimum distance from the triangle to the center of the sphere. Mathematically, this could be a minimization double integral in barycentric coordinates. If the distance is less than r then you have a collision.
If you just need a discrete test, I'd go for this method. The info returned by the closest point test can be used to resolve the intersection, which also gives you fairly natural sliding collision response. This will only work for objects that move relatively slowly, though.

Share on other sites
Hey!! I have posted the correct method here (your thread on the DirectX forum)...

Sorry man, Ive wrote the wrong code but now its right...the problem was with the s and t computation...just confused with the distance between a point and a line computation :P...read that and if you have any questions its just ask ;)

Share on other sites
Quote:
 Mathematically, this could be a minimization double integral in barycentric coordinates. If the distance is less than r then you have a collision.

Would you mind elaborating/posting a source on this?

Share on other sites
phb5000, please read this excellent article by David Eberly. You can find the source code as well at his site.

Quote:
 Original post by jjdProject the position (center) of the sphere along the surface normal. If the value is greater than the spheres radius, the sphere doesn't penetrate the triangle so break. Otherwise, find the image of the sphere projected on the plane and test whether that point is inside the triangle.

Unfortunately, this is not enough. Even if the sphere center's projection onto the plane is outside the triangle, the sphere can still collide with the triangle.

WhardieJones, didn't you mean to minimize the distance function between the sphere's center and the triangle? In any case, this is not a "simple" minimization problem because the barycentric coordinates are subject to the following constraints:
0 <= s,t
1 >= s+t

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 13
• 9
• 12
• 9
• Forum Statistics

• Total Topics
631437
• Total Posts
3000063
×