简体   繁体   English

如何从多个点找到最远的 x, y 坐标?

[英]How to find the farthest x, y coordinates from many points?

I have a set of random points in a plane and I want to put another point at the most "sparse" position.我在平面上有一组随机点,我想在最“稀疏”的位置放置另一个点。

For example, if there are some points in 0 < x < 10 and 0 < y < 10:例如,如果在 0 < x < 10 和 0 < y < 10 中有一些点:

# this python snippet just generates the plot blow.
import matplotlib.pyplot as plt

# there are actually a lot more, ~10000 points.
xs = [8.36, 1.14, 0.93, 8.55, 7.49, 6.55, 5.13, 8.49, 0.15, 3.48]
ys = [0.65, 6.32, 2.04, 0.51, 4.5, 7.05, 1.07, 5.23, 0.66, 2.54]
plt.xlim([0, 10])
plt.ylim([0, 10])
plt.plot(xs, ys, 'o')
plt.show()

在此处输入图片说明

Where should I put a new point in this plane so that the new point becomes the most distant from the others?我应该在这个平面的什么地方放置一个新点,以便新点与其他点最远? Please note that I want to maximise the minimum distance to another point, but not to maximise the average distance to all other points (Thanks to user985366's comment ).请注意,我想最大化到另一个点的最小距离,而不是最大化到所有其他点的平均距离(感谢user985366 的评论)。

" How can I find the farthest point from a set of existing points? " is the one at least I could find, but I'm not sure if the page directly solves my situation (actually the linked case looks more complicated than my case). 如何从一组现有点中找到最远的点? ”至少是我能找到的,但我不确定该页面是否直接解决了我的情况(实际上链接的案例看起来比我的案例更复杂) .

[edit] By the way, I noticed that general constrained global optimization can find a possible solution (if I add a point at each corner) [4.01, 5.48] in this case, but I think it doesn't work if there are a lot more, say ~10000 points. [编辑] 顺便说一句,我注意到在这种情况下,一般约束全局优化可以找到一个可能的解决方案(如果我在每个角落添加一个点)[4.01, 5.48],但我认为如果有还有很多,比如说~10000点。

Your problem can be solved by computing the Voronoi diagram of the set of points.您的问题可以通过计算点集的Voronoi 图来解决。 This is a division of the plane into regions such that there is one region per point in the original set, and within that region, the corresponding point is closer than other points from the set.这是将平面划分为多个区域,使得原始集合中的每个点有一个区域,并且在该区域内,对应点比集合中的其他点更近。

The boundaries of these regions are straight lines such that any point on that line is equidistant from the two points corresponding to the regions which meet at that boundary.这些区域的边界是直线,使得该线上的任何点与在该边界处相交的区域对应的两个点的距离相等。 The vertices where multiple boundaries meet are therefore equidistant to at least three points from the original set.因此,多个边界相交的顶点与原始集合的至少三个点等距。

The sparsest point in the plane is either a vertex in the Voronoi diagram, or the intersection of an edge in the Voronoi diagram with the boundary of the plane, or one of the corners of the plane.平面中最稀疏的点要么是 Voronoi 图中的一个顶点,要么是 Voronoi 图中的一条边与该平面的边界或该平面的一个角的交点。 The Voronoi diagram can be computed by standard algorithms in O(n log n) time; Voronoi 图可以通过标准算法在 O(n log n) 时间内计算出来; after this, the sparsest point can then be found in linear time, since you know which Voronoi regions each vertex/edge is adjacent to, and hence which point from the original set to measure the distance to.在此之后,可以在线性时间内找到最稀疏的点,因为您知道每个顶点/边与哪些 Voronoi 区域相邻,因此您知道原始集合中的哪个点要测量到的距离。

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

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