Search code examples
algorithm3dintersectionpolygons

Intersection between 3D flat polygons


How to find intersections between two (or more) 3D planar polygons (for the simplest case they are all convex)? Seeking algorithms able to provide the intersection line if there is any. Note the methods proposed for infinite Plane-Plane cases are not useful.


Solution

  • There are 2 cases:

    Both polygons lie on the same plane.

    Find all internal points to the first polygon.

    Arbitrarily take the first polygon, loop through all the vertices of the 2nd polygon and determine whether they lie inside or outside the first polygon. Doing this is easy for convex polygons: see here.

    Find the intersection points between the 2 polygons

    To find the intersection points take each edge of one of the polygons and loop through all the edges of the other polygon to find if they intersect anywhere. this can be found by using the formula for the intersection of 2 lines.

    The intersected region is the polygon formed with vertices at the internal points and the intersected points.

    The 2 polygons lie on different planes.

    Find the intersection of the 2nd polygon with the plane of the first one. You can do this by considering each edge of the 2nd polygon, and finding the intersection between the edge and the plane of the first polygon. This can be found using the formula for the intersection between a line and a plane.

    Check whether the intersection points you found lie inside or outside of the first polygon.