我使用区域来查找两条路径的交集(由两个多边形创建)。
GraphicsPath gp1 = new GraphicsPath();
gp1.AddPolygon(P);//P - array of points [first polygon]
Region d = new Region(gp1);
GraphicsPath gp2 = new GraphicsPath();
gp2.AddPolygon(P_);//P_ - array of points [second polygon]
d.Intersect(gp2);//founded intersection
我怎样才能得到d区的交点?
我建议使用适合此任务的多边形交集库。
这是一个可以从 C# 中使用的最优秀的一个
http://www.angusj.com/delphi/clipper.php
如果需要,我也确信还有许多其他用 C# 编写的。以下是关于该主题的SO问答:
如何与两个多边形相交?
使用 检查图形路径是否相交
if(!d.IsEmpty(this.CreateGraphics())
{
RectangleF rectBound=d.GetBound(this.CreateGraphics());
Pointf intersectionPoint=new Pointf(rectBound.X+rectBound.Width/2,rectBound.Y+rectBound.Height/2);
}