Find nearest neighbor with morton code

Viewed 1594

I have implemented a decode/encode method for transforming 2d points into their respective morton code.

What am i looking for is to find the nearest neighbor (under a min_distance) So for example something like this:

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)

Is this possible?

1 Answers
Related