您好,我使用C和我想找到一个多边形(主要是三角形)给我,我必须找到一个给定的点存在于给定的多边形或不知道,我想知道,有任何功能,在C ^,这可以为我做,或任何有效的ALGO这样做?是吗?
多边形在二维平面上由XY点表示给定点也由XY点表示
先走一步。

最佳答案

您需要使用Graphics.IsVisible(Point p)
它指示由一对坐标指定的点是否包含在此图形对象的可见剪裁区域内。
MSDN样品:

public void IsVisiblePoint(PaintEventArgs e)
{
   // Set clip region.
   Region clipRegion = new Region(new Rectangle(50, 50, 100, 100));
   e.Graphics.SetClip(clipRegion, CombineMode.Replace);
   // Set up coordinates of points.
   int x1 = 100;
   int y1 = 100;
   int x2 = 200;
   int y2 = 200;
   Point point1 = new Point(x1, y1);
   Point point2 = new Point(x2, y2);
   // If point is visible, fill ellipse that represents it.
   if (e.Graphics.IsVisible(point1))
   e.Graphics.FillEllipse(new SolidBrush(Color.Red), x1, y1, 10, 10);
   if (e.Graphics.IsVisible(point2))
   e.Graphics.FillEllipse(new SolidBrush(Color.Blue), x2, y2, 10, 10);
}

关于c# - 如何找到该点是否存在于任何多边形区域中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3140051/

10-11 04:08
查看更多