0
Points
0
Depth
โ
NN Distance
Ready
Status
120 ms
X-split line
Y-split line
Point
Query / Path
Nearest neighbor
How it works
A KD-tree recursively partitions 2D space by alternating between X and Y axes. Each node splits the plane with a vertical (red) or horizontal (blue) line.
- Click the canvas to add a point. The tree rebuilds to show the new partitioning.
- Toggle NN Mode, then click to place a query point โ the nearest neighbor is found and highlighted in green.
- The search path through the tree animates to show how spatial pruning works.