In a cubic box I have a large collection points in R^3. I\'d like to find the k nearest neighbors for each point. Normally I\'d think to use something like a k-d tree, but in th
Even in the Euclidean case, a point and its nearest neighbor may be on opposite sides of a hyperplane. The core of nearest-neighbor search in a k-d tree is a primitive that determines the distance between a point and a box; the only modification necessary for your case is to take the possibility of wraparound into account.
Alternatively, you could implement cover trees, which work on any metric.