我有一组点,想找到凸壳。当我把它们给凌乱的空间(不管是ConvexHull还是Delaunay),我只是把原来的一组点取回来。从结构上看,情况不应该如此。在
这里是the points作为pickled numpy数组。我的代码如下:
import pickle
from scipy import spatial
import matplotlib.pyplot as plt
points = pickle.load( open( "points.p", "rb" ) )
hullpoints = spatial.ConvexHull(points).points
# plot points
fig = plt.figure()
ax = fig.gca(projection='3d')
# ax.plot(points[:, 0], points[:, 1], points[:, 2], 'r.') # original points
ax.plot(hullpoints[:, 0], hullpoints[:, 1], hullpoints[:, 2], 'r.') # convex hull of points
# set labels and show()
ax.set_xlabel('Player 1')
ax.set_ylabel('Player 2')
ax.set_zlabel('Player 3')
plt.show()
显然,其中一些点位于凸壳内部,应通过空间.ConvexHull(点)或空间。德劳内(点),如给出的2d示例here。在
有人知道我为什么要拿回原来的分数吗?表面上的目标似乎是我能找到的终极点凌乱的空间应该能做到这一点。在
您使用的是返回输入点的
.points
属性。试着使用.simplices
属性,它提供了“形成凸壳的简单面的点”。在See the documentation for more info.
相关问题 更多 >
编程相关推荐