简体   繁体   English

如何确定 3d 点是否位于某个体积内?

[英]How to determine if 3d point lie in a certain volume or not?

I have a set of 3d points in a txt file in the form of (x,y,z) as shown in figure 1. I want to specify the boundaries of these points as in figure 2 such that if any new points were added outside the boundaries they are deleted as the blue points, and if they are inside the boundaries as the green ones they are kept.我在 txt 文件中有一组 3d 点,格式为 (x,y,z),如图 1 所示。我想指定这些点的边界,如图 2 所示,以便在外部添加任何新点边界它们被删除为蓝色点,如果它们在边界内,则保留为绿色点。 How can I achieve that in python?我怎样才能在python中实现这一点? I tried convex hull but it only gets the boundary points !我试过凸包,但它只得到边界点!

The real data can be found here, I used figures for simplification.真实数据可以在这里找到,我用数字来简化。 https://drive.google.com/file/d/1ei9NaJHN922pYItK2CRIXyLfwqm_xgrt/view?usp=sharing https://drive.google.com/file/d/1ei9NaJHN922pYItK2CRIXyLfwqm_xgrt/view?usp=sharing

Figure 1

在此处输入图像描述

Figure 2

在此处输入图像描述

For 2D points, you can apply the test as described in Wikipedia :对于 2D 点,您可以按照Wikipedia中的描述应用测试:

One simple way of finding whether the point is inside or outside a simple polygon is to test how many times a ray, starting from the point and going in any fixed direction, intersects the edges of the polygon.确定该点是在简单多边形内部还是外部的一种简单方法是测试从该点开始并沿任何固定方向行进的射线与多边形边缘相交的次数。 If the point is on the outside of the polygon the ray will intersect its edge an even number of times.如果该点位于多边形的外部,则光线将与它的边缘相交偶数次。 If the point is on the inside of the polygon then it will intersect the edge an odd number of times.如果该点位于多边形内部,则它将与边缘相交奇数次。 The status of a point on the edge of the polygon depends on the details of the ray intersection algorithm.多边形边缘上的点的状态取决于光线相交算法的细节。

The n-dimensional case involves a convex hull test and requires linear programming techniques as described here . n 维情况涉及凸包测试,并且需要此处描述的线性编程技术。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM