Search code examples
c#polygonintersectionsystem.drawing

How can I tell if two polygons intersect?


Imagine I have the coordinate of 4 points that form a polygon. These points are represented using PointF in C#. If I have 2 polygons (using 8 points), how can I tell if they intersect?

Rectangle class has a method called IntersectsWith but I couldn't find something similar for GraphicsPath or Region.

Any advice would be greatly appreciated.

Mosh


Solution

  • As Charlie already pointed out you can use the Separating Axis theorem. Check out this article for a C# implementation and example of polygon collision detection.

    I have also answered this question here which deals with 2D collision in C#.