【发布时间】:2018-04-19 23:08:56
【问题描述】:
我想在三维立方体中找到离 n 个其他点最远的点[s]。我试着玩弄 scipy.spatial.Voronoi,但我想不通(我得到的答案在立方体之外)。我不太擅长这种类型的数学,如果你能将我推荐给一个可以完成大部分数学运算的库或一些我可以复制的代码,我将不胜感激。
编辑:我看到请求图书馆是多么离题,当然所有有用的答案都将受到高度赞赏!感谢 Mathieu 的回答,我想我对自己的问题有了更好的理解。
我尝试的是:
import numpy as np
from scipy.spatial import Voronoi
def get_points(points)
np_points = np.array(points)
vor = Voronoi(np_points)
fartest_point = None
fartest_point_length = np.inf
for vertex in vor.vertices:
min_length = np.inf
for p in points:
length = norm(p-vertex)
if length < min_length:
min_length = length
if min_length < fartest_point_length:
fartest_point = vertex
fartest_point_length = min_length
return fartest_point
points = [[2, 3, 5], [8, 2, 6], [10, 3, 5], [2, 3, 2], ...]
point = get_points(points)
问题是我得到了立方体之外的点。我认为问题在于我没有得到该区域与立方体边缘接触的点。
【问题讨论】:
-
您可能需要定义“距离其他 n 个点最远”。它不会成为顶点之一吗?顺便说一句,我不是反对者;)
-
欧式距离。你能解释一下“它不会成为顶点之一”是什么意思吗?
-
你不是只需要检查立方体的八个不同点吗?
-
我投票结束这个问题作为离题,因为这个网站是为了帮助程序员,而不是找到你可以在不理解的情况下“复制”的代码位。
-
否,因为它可以是多维数据集中的任何点。例如,如果 n 个点靠近一个角落,那么离所有这些点最远的点将在中间。我认为我遇到的问题是Largest empty sphere problem
标签: python python-3.x numpy scipy discrete-mathematics