Tell me more ×  I have a 2D map which wraps at the edges. So if
you move off the right edge you will reappear at the left side
of the map. Likewise with the three other edges.  This is
inheritable a problem for the KDTree which I use to find
elements in range of points. Normally you would check whether
the hyper sphere collisdes with the hyper plane to see if you
should continue searching the other side of the tree, but this
check does not work with wrapping edges.  Is there any way to
modify the KD Tree to work with donut 2D spaces?  share|improve
this question add comment  3 Answers  Jitamaro suggested but
didn't explain a method based on a "2x size" quadtree. It's a
reasonable suggestion, except the quadtree uses four times as
many nodes rather than two, as I'll explain below before
tentatively suggesting an alternative method.  Suppose each
(x,y) coordinate has -.5 < x <= .5 and -.5 < y <= .5 and
whenever j, k are integers, point (x+j,y+k) is identical with
point (x,y). Let quadtree T cover points with co