作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一组点,想找到凸包。当我将它们交给 scipy.spatial(ConvexHull 或 Delaunay)时,我只是得到了原始的点集。按照结构,这不应该是这种情况。
这是 the points作为腌制的 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()
显然,其中一些点位于凸包内部,应通过 spatial.ConvexHull(points) 或 spatial.Delaunay(points) 删除,如给出的二维示例中所做的那样 here .
有谁知道我为什么要找回原来的积分集?我可以蛮力找到外部点并仅绘制那些(最终目标是由点近似的外部形状的表面图),但似乎 scipy.spatial 应该能够做到这一点。
最佳答案
您正在使用 .points
属性返回输入点。尝试改用 .simplices
属性,它为您提供“形成凸包的简单面的点”。
关于python - scipy.spatial 中的凸包例程让我恢复了原来的点集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19391811/
如何使用 Blazor 在 Linux 平台下运行 Desktop 程序 本文将讲解如何使用 Blazor 运行跨平台应用,应用到的技术有以下几点 Blazor
低并发的友友们好,我是闪客。 Lambda 表达式非常方便,在项目中一般在 stream 编程中用的比较多。 List<Student> studen
我是一名优秀的程序员,十分优秀!