Skip to main content
100%

Closest Line Segment

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

A brushless interaction demonstrates nearest-neighbor search over line segments. As the mouse moves, a red highlight identifies the closest segment to the cursor, with the active segment brought to the front. The example builds a binary tree of segment bounding boxes to accelerate the search, using a custom min-heap to prune distant branches. The segment geometry derives from a sine wave, rendered as SVG paths via `d3.geo.path`. The search logic is implemented in a standalone `tree.js` module, while `d3.mouse` handles coordinate tracking.

AI-generated description
gpl-3.0 Licensed

Similar vizzes