如何获得二维几何中包含的所有点?

编程入门 行业动态 更新时间:2024-10-26 19:28:32
本文介绍了如何获得二维几何中包含的所有点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将所有点包含在二维几何体中? 如何知道一个点是否包含二维几何? 我需要一个内置的顺便说一下,不是复杂的数学。

How to get all points contained inside a 2d geometry? How to know whether a point is contained withing a 2d geometry or not? I need a built-in way, not complex math.

推荐答案

我的假设: - 你对2D场景感兴趣 - 你有一组N分(只有在N> 3的情况下才有用) 这个2D的一般解决方案是: 确定点集的凸包。怎么做你可以找到,例如 en.wikipedia/wiki/Quickhull [ ^ ] 每个点都不在结果中凸壳在里面。凸包的点是在边界。 你可以扩展3D场景。 我希望它有所帮助。 问候 My assumptions: - You are interesting in a 2D Scenario - You have a set of N points (only intersting in case N > 3) A General solution for this 2D is: Determine the convex hull for your set of Points. How to do that you can find e.g. en.wikipedia/wiki/Quickhull[^] Every Point which is not in the result of the convex hull is inside. Points of the convex hull are "at the border". You can that extend also for 3D Scenarios. I hope it helps. Regards

您的问题没有解决方案。 您希望的功能非常专业,您不会在通用框架中找到它。 您的唯一方法是编写复杂的自我编程或查找代码示例。 或多或少,您必须将2D任意几何转换为具有一些特殊数学属性的几何,以便检查是否有点是否内部。 - 转换是将几何体分解成许多凸起部分 - 该点必须位于其中一个部分内。 There is no solution to your question the way you want. The function you wishes is highly specialized and you will not find it in a general purpose framework. Your only way is to program complex math your self or find examples of code. More or less, you have to transform your 2D arbitrary geometry into a geometry that have some special math properties that allow to check if a point is inside or not. - the transform is to break the geometry into many convex parts - the point have to be inside one of the parts.

是的,这是可能的。 Geometry.FillContains方法(Point) [ ^ ] 积分变量是2d几何中包含的所有点的列表(geom)。 代码: Yes, it is possible. Geometry.FillContains Method (Point)[^] "points" variable is a list of all points contained within a 2d geometry (geom). Code: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.Loaded += MainWindow_Loaded; } void MainWindow_Loaded(object sender, RoutedEventArgs e) { RectangleGeometry rectgeom = new RectangleGeometry(new Rect(0, 0, 10, 10)); Geometry geom = rectgeom; List<Point> points = GetPoints(geom); // Points contained within a 2d geometry } private List<Point> GetPoints(Geometry geom) { List<Point> points = new List<Point>(); for (int i1 = 0; i1 < 100; i1++) for (int i2 = 0; i2 < 100; i2++) if (geom.FillContains(new Point(i1, i2))) points.Add(new Point(i1, i2)); return points; } }

更多推荐

如何获得二维几何中包含的所有点?

本文发布于:2023-10-13 14:28:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1488209.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几何   如何获得

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!