凸壳例程凌乱的空间把我原来的观点还给我

2024-03-29 15:31:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一组点,想找到凸壳。当我把它们给凌乱的空间(不管是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。在

有人知道我为什么要拿回原来的分数吗?表面上的目标似乎是我能找到的终极点凌乱的空间应该能做到这一点。在


Tags: importplotshowfig空间pltaxpickle