给出起始数组[[0,0],[1、0],[0、1]]。如何在python中的2D空间中找到下一个最近的可用点(按距(0,0)的距离)?在pic1中找到下一个可用的红点(按距(0,0)的距离)?在追加数组之后,在pic2中再次在红点中找到下一个可用的对象(按与(0,0)的距离),并保持增长?
伪代码:
Sort by Min(delta_x, delta_y)
set `best_distance` to DOUBLE.MAX
as long as entries are below `best_distance`,
get squared distance d2 = delta_x^2 + delta_x^2;
if best_distance>d2
best_distance = d2