Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

voronoi tiling goes a bit crazy when points are duplicated in the input #118

Closed
blackmad opened this issue Nov 28, 2020 · 1 comment
Closed

Comments

@blackmad
Copy link

blackmad commented Nov 28, 2020

update: 100% sure this is due to repeated or near-repeated points in the input. Not sure if this is a bug or something you want to fix or try to help clients of the library not shoot themselves in the foot doing. Happy to close this as a user_error_wont_fix.

tl;dr: I noticed today that having repeated points (or near-repeated points because floating point numbers) causes d3-delaunay to return very strange tilings.


I built a tool that makes extensive use of d3-delaunay, and today when messing around with it I ended up in this surprising state:
image
(if you follow the blue, it's the raw output of d3-delaunay, you can see that those middle circles are pulling up in a weird way). My code uses cellPolygons and iterates over the points of each polygon.

I put the parameters I was using into an observable notebook and got a slightly different, but still broken tiling:
https://observablehq.com/@blackmad/voronoi-neighbors
image
(blue are seed points) - notice how those round-ish tiles in the center don't meet?

I don't know how to debug this further. Is this a bug in d3-delaunay?

@blackmad blackmad changed the title voronoi appears to be wrong? Nov 28, 2020
@mourner
Copy link
Collaborator

mourner commented Nov 28, 2020

This is a numerical robustness issue — Delaunator (the underlying library) fails on certain cases with convoluted floating point data. If I round the coordinates (in this case to 2 decimal points), it works properly:
image

Closing in favor of mapbox/delaunator#61 — there is a workaround for the library but it would increase the dependency size quite a bit, so I'm thinking of producing multiple builds (robust and lite non-robust).

@mourner mourner closed this as completed Nov 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants