带有 scipy.spatial.Delaunay 的 Python 凸包,如何消除船体内的点?

标签 python numpy scipy convex-hull delaunay

我在名为 pointsList 的 np.array 中有一个 3D 点列表,值为 float :

[[1., 2., 10.],
 [2., 0., 1.],
 [3., 6., 9.],
 [1., 1., 1.],
 [2., 2., 2.],
 [10., 0., 10.],
 [0., 10., 5.],
... etc.

此代码对点云进行 Delaunay 三角剖分:

import numpy as np
import scipy.spatial 

tri = scipy.spatial.Delaunay(pointsList) 
# Delaunay triangulation

indices = tri.simplices
# indices of vertices

vertices = points[indices]
# the vertices for each tetrahedron

但是,在该三角测量步骤之前,我想从我的列表中删除凸包内部的所有点

一个解决方案是创建一个名为 shortlist 的新 np.array,并将它们存储在那里。

但是 scipy(或任何其他解决方案)中的哪个函数可以做到这一点?

我该如何编程这个操作?

谢谢

最佳答案

凸包是 Delaunay 三角剖分的子图。

所以你可能只使用 scipy.spatial.ConvexHull() ,即。 g.

from scipy.spatial import ConvexHull
cv = ConvexHull(pointList)

hull_points = cv.vertices
# the vertices of the convex hull

set(range(len(pointList))).difference(ch.vertices)
# the vertices inside the convex hull

比较 scipy.spatial.Delaunayscipy.spatial.ConvexHull (2D)

enter image description here

关于带有 scipy.spatial.Delaunay 的 Python 凸包,如何消除船体内的点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21727199/

相关文章:

python - 如何解析使用单引号的类似 JSON 的语法?

python - 如何使用已保存模型中的 pk 提供成功 url?

python - np.multiply 如何工作?

c++ - 使用 OpenCV 计算特征值、特征向量

python - keras 中 model.predict() 和 model.predict_generator() 之间的预测差异

python - 按住按钮和窗口更新问题

python - 从 dtype 创建一个 Numpy 标量

python - 自定义损失函数: NotImplementedError: Cannot convert a symbolic Tensor (truediv_2:0) to a numpy array

python - 相当于python中Matlab的gaminv

python - 如何在 numpy/scipy 中生成带有圆圈的矩阵