作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
你好,我正在使用 C#,我想知道是否有一个多边形(主要是三角形)给我,我必须找到给定的点是否存在于给定的多边形中,我想知道是否有任何函数在 c# 中可以为我做这件事或任何有效的算法吗??
多边形在 2D 平面中由 XY 点表示,给定点也由 XY 点表示
提前致谢
最佳答案
您需要使用 Graphics.IsVisible(Point p) .指示由一对坐标指定的点是否包含在该 Graphics 对象的可见裁剪区域内。
来自 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/
我有数百个位置的列表,只想显示当前屏幕上这些位置的 MKPinAnnotation。屏幕从 2 英里半径内的用户当前位置开始。当然,用户可以滚动和缩放屏幕。现在,我等待 map 更新事件,然后循环遍历
我试过检查 CGRect: CGFloat imageX1 = imageView.frame.origin.x; CGFloat imageY1 = imageView.frame.origin
我是一名优秀的程序员,十分优秀!