问题描述
想象一下,我有4个点形成的多边形的坐标。这些要点在C#中使用的PointF表示。如果我有2个多边形(使用8点),我怎么能知道,如果他们相交?
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?
矩形类有一个叫做IntersectsWith方法,但我无法找到的GraphicsPath或地区类似的东西。
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
推荐答案
由于查理已经指出的那样,你可以使用分离轴定理。
查看的C#实现和示例多边形碰撞检测。
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.
我也回答了这个问题的这与C#2D碰撞交易。
I have also answered this question here which deals with 2D collision in C#.
这篇关于我怎样才能知道,如果两个多边形相交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!