Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用morton代码查找最近的邻居_Python_Nearest Neighbor_Z Order Curve - Fatal编程技术网

Python 使用morton代码查找最近的邻居

Python 使用morton代码查找最近的邻居,python,nearest-neighbor,z-order-curve,Python,Nearest Neighbor,Z Order Curve,我已经实现了一种解码/编码方法,用于将2d点转换为各自的莫顿码 我要找的是找到最近的邻居(在最小距离下) 举个例子: points=[(200,300),(500,150),(100,50)] mortonCodes = {} for p in points: mortonCodes[encode(p)] = p nearest = findNearestNeighbor(mortonCodes, (201,305)) print(nearest) # ---> should r

我已经实现了一种
解码/编码
方法,用于将2d点转换为各自的
莫顿码

我要找的是找到最近的邻居(在
最小距离下
) 举个例子:

points=[(200,300),(500,150),(100,50)]
mortonCodes = {}
for p in points:
    mortonCodes[encode(p)] = p

nearest = findNearestNeighbor(mortonCodes, (201,305))
print(nearest) # ---> should return (200,300)

这可能吗

您可以使用
minu distance
执行以下操作,例如120: 使用查询点
qp=(201305)
并通过减去/添加距离来创建最小点和最大点:
min=(81185)
max=(321425)
。 现在,为这两点创建morton代码


所有距离(210305)120以内的点都将有一个莫顿代码
mcWithin120
with
mortonCode(min)是的,你是对的,我会投票,因为我不知道PH树,我认为这将是更好的解决方案!还可以看看这一点,特别是在使用morton order进行kNN搜索时引用PDF的注释。