Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Triangle vs Sphere collison detection Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
David Kosenina

March 07, 2005, 05:18 AM

Haw to do triangle sphere collision detection?


bool TriangleSphere( a, b, c, pos, radius )
{

}

 
Crash

March 07, 2005, 08:59 AM

Find the closest point on the triangle to the center of the sphere, and then see if it's inside the radius of the sphere.

-M

 
Rui Martins

March 07, 2005, 09:34 AM

Find the closest point on the triangle to the center of the sphere, and then see if it's inside the radius of the sphere.


In other words, find the distance of every triangle vertex to the sphere center.
If distance < radius then true.
You can and should use the (square_distance < square_radius) to avoid the Square Root.

This is a simple yes or no, it won't give you how or where it hit the sphere.

Also it may not work if any of the objects is moving (tri or Sphere), if the velocity (speed) is to great or if the time step is long, making possible to miss the collision.

NOTE: But there are a bunch of articles/tutorials on this subject already, make a search for it, including here on Flipcode.

 
Fabian 'ryg' Giesen

March 07, 2005, 10:04 AM

This is a rejection test, not a collision test.

Even if it fails, the triangle may still intersect the sphere. Think of a big triangle through the center of a tiny sphere - all the triangles' vertices are outside the sphere, yet still there is an intersection.

 
Fabian 'ryg' Giesen

March 07, 2005, 10:06 AM

Refer to the Object/Object intersection page: http://www.realtimerendering.com/int/.

 
Rui Martins

March 07, 2005, 11:14 AM

You are right Fabian, I let that one slip through =;) Literally !

 
David Kosenina

March 08, 2005, 06:16 AM

Helo

I am looking for a complete and fast intersection test.
Does anybody have ERIT and has tryed it. This should be a complete library for intersection tests. I send a request to the auther for the source code.

 
This thread contains 7 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.