-
Notifications
You must be signed in to change notification settings - Fork 56
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
don't break when there are few or collinear points #62
Conversation
fixes #50 note: I had to disable the tests for outeredges, because I'm not using the same outeredges (but they do point to the same nodes).
Rebased (with some clean-ups) on the indexHull branch. Updated the test at https://observablehq.com/d/5e4da35146afd543 |
Personally this looks too hacky to be worth the benefit in this form... Can we approach the issue some other way, including changes to Delaunator upstream? The "try/catch" just feels like a blanket cover fix, and depending on a constant number to designate "far away" doesn't feel right too — e.g. I can easily imagine Delaunay being fed some big numbers in this range. |
Agreed. In d3-geo-voronoi in particular, the numbers can be very large after the stereographic projection — and there is already too much numeric instability (see Fil/d3-geo-voronoi#10). I wonder if the solution wouldn't be to return an empty With this approach Delaunator would not lie about triangles ("here's your 0 triangles"), and just a little bit about the hull. d3-delaunay could work with that pseudo-hull and create the list of infinite cells in that order. |
New code, much cleaner. Updated the tests at https://observablehq.com/d/5e4da35146afd543. Needs this change to Delaunator: https://github.com/Fil/delaunator/commit/b96802021867a788c2c2111085562a086996b52c |
the strategy is the following: - instead of throwing an error for collinear input, Delaunator returns a degenerate structure with hull = the valid points, sorted along an arbitrary axis (https://github.com/Fil/delaunator/commit/b96802021867a788c2c2111085562a086996b52c) - the cases with 1 or 2 valid points are handled specifically; - for 2 points, craft fake triangles to create the correct vectors - the case with 3 or more valid point is handled by jittering the points (deterministically); however neighbors are handled specifically, using the ordered list returned as "hull" by Delaunator
with a possibly superfluous test on i0 to avoid infinite looping if no point is regular fixes #55
… less than 2 points (ie no triangulation)
Superseded by #64. |
* return an ordered array of points if they are collinear (see d3/d3-delaunay#62) * test * simplify: collinear inputs can be sorted by x (or by y if all x are identical)
fixes #19 and #20
gross (try/catch)this is not ready to merge: there are issues with (at least):naming (this.__
property is a placeholder)tuning the value ofg
(1e9 works in the examples but creates some instability, as evidenced by the fact that lines are not neat — with 1e8 they are perfectly in the middle).should the API allow to request a strict Delaunay — or on the contrary, offer this "robust" approach as an option?