使用scipy.spatial.Delaunay的Python凸包,如何消除凸包内部的点?

7

我有一个名为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(或任何其他解决方案)中,有哪个函数可以做到这一点?

我该如何编写此操作的程序?

谢谢

1个回答

15
凸包是Delaunay三角剖分的子图。因此,您可以使用scipy.spatial.ConvexHull()。例如,
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


1
你是怎么绘制那个图像的? - TripShock
@TripShock 这是两张图片。我使用matplotlib提供的散点数据(散点图)和连接顶点的数据(折线图)。通过simplices属性中的索引,您可以获取到连接的顶点数据。 - embert
@embert 感谢您的回答,但是在执行 ConvexHull 操作之后,我该如何计算 Delaunay 三角剖分呢? - adrienlucca.net
1
@adrienlucca.wordpress.com 为什么你想要这样做?你可以执行 Delaunay 一次 (scipy.spatial.Delaunay),这样做,你也会有 ConvexHull 可用 (scipy.spatial.Delaunay.convex_hull)。 - embert

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接