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

前端 未结 5 1183
广开言路
广开言路 2020-12-08 23:37

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.

5条回答
  •  渐次进展
    2020-12-08 23:42

    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.

提交回复
热议问题