我在名为 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.Delaunay
和 scipy.spatial.ConvexHull
(2D)
关于带有 scipy.spatial.Delaunay 的 Python 凸包,如何消除船体内的点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21727199/