繁体   English   中英

Python凸壳与scipy.spatial.Delaunay,如何在船体内部分点?

[英]Python convex hull with scipy.spatial.Delaunay, how to eleminate points inside the hull?

我有一个名为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

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

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

scipy (或任何其他解决方案)中的哪些功能会做到这一点?

我该如何编程这个操作?

谢谢

凸壳是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)

在此输入图像描述

暂无
暂无

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

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