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
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#.
Strictly speaking, the other answers suggesting an algorithm are probably your best bet. But performance aside, you mentioned that you couldn't find anything like IntersectsWith for GraphicsPath or Region. However there is an Intersect method that updates a region to be the intersection of itself and another region or path. You could create two regions, Intersect() one with the other, then test for Region.IsEmpty().
But I imagine this is probably a pretty slow way to do it and would probably result in a lot of allocations if done in a loop.
If your polygons are convex then you should be able to use separating axis theorem. A demo is available here (It's in actionscript but the code should be easy to port to c#)
This is really not my area but I hope it helps anyway.
This is an old question, but I thought I would share my solution also. Region.IsEmpty() requires a Graphics context and from my understanding is only designed to perform pixel precision hit testing. This is not ideal for many situations. A much better solution is to use the Clipper library by Angus Johnson. In my experience this is a fast well tested library. You can provide your own precision and it handles extremely complex polygons.
http://www.angusj.com/delphi/clipper.php
There is a C# implementation. What you would need to do is perform an intersection operation just like the System.Drawing.Region method. Then examine the result of the operation. If it is empty there was no intersection. If it contains data then the data is the intersecting points.
http://www.angusj.com/delphi/clipper/documentation/Docs/Units/ClipperLib/Types/ClipType.htm
Some methods you would find useful for this.
And to perform an intersection