d3 / d3-delaunay

Compute the Voronoi diagram of a set of two-dimensional points.
https://d3js.org/d3-delaunay
ISC License
611 stars 57 forks source link

Edges that both sides are clipped sometimes will not be identified as voronoi neighbor #137

Closed UnluckyNinja closed 1 year ago

UnluckyNinja commented 1 year ago

image Reproduction: https://observablehq.com/d/3e65ad730f4712fc Green lines visualize voronoi neighbors, red ones visualize delaunay-only neighbors. If you change the first 3 parameters, cell 0-4, 1-5, 3-7, 2-6 are no longer neighbors occasionally. It seems it only happens on both sides clipped edges. Edges that at least one end of it resides in viewbox are fine.

Fil commented 1 year ago

Yes. It happens on https://github.com/d3/d3-delaunay/blob/2196b80926a0b68e40c1f416b634f8a4a0a11208/src/voronoi.js#L154

I have also reproduced the issue here: https://observablehq.com/@d3/voronoi-neighbors-137

UnluckyNinja commented 1 year ago

Tried the fixed version from #138 in my notebook. It's consistently and correctly recognized for the clipped edges now. Very much appreciated.