Skip to main content
100%

Quadtree Search

✓ Published0🌍 Public
Mmbostock
Last edited Oct 9, 2016
Created on Feb 18, 2014

This example shows a quadtree search for the nearest point to the mouse cursor among 2,500 randomly generated points. As the cursor moves, the closest point is highlighted in red. The visualization renders the quadtree’s subdivisions as gray rectangles and the points as black circles using SVG. It uses d3.quadtree with the find method, along with d3.mouse and quadtree.visit to display the search hierarchy.

AI-generated description

This demonstrates finding the closest point to the mouse by searching a quadtree. As you descend into the quadtree, you track the closest point yet found and avoid searching cells that cannot contain closer points. Importantly, you must descend preferentially into closer cells so as to restrict the search more quickly.

Patrick Surry implemented a similar solution months earlier!

gpl-3.0 Licensed

Similar vizzes