What's the most efficient way to detect triangle-triangle intersections?

José Joel. picture José Joel. · Oct 18, 2009 · Viewed 19.4k times · Source

How can I tell whether two triangles intersect in 2D Euclidean space? (i.e. classic 2D geometry) given the (X,Y) coordinates of each vertex in each triangle.

Answer

Nick Dandoulakis picture Nick Dandoulakis · Oct 18, 2009

One way is to check if two sides of triangle A intersect with any side of triangle B, and then check all six possibilities of a point of A inside B or a point of B inside A.

For a point inside a triangle see for example: Point in triangle test.

When we test collisions on polygons we also have a surrounding rectangle for our polygons. So we first test for rectangle collisions and if there is a hit we proceed with polygon collision detection.