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

don't break when there are few or collinear points #62

Closed
wants to merge 14 commits into from
Closed

Conversation

Fil
Copy link
Member

@Fil Fil commented May 22, 2019

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 of g (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?
@Fil
Copy link
Member Author

Fil commented May 22, 2019

Rebased (with some clean-ups) on the indexHull branch.

Updated the test at https://observablehq.com/d/5e4da35146afd543

@mourner
Copy link
Collaborator

mourner commented May 22, 2019

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.

@Fil
Copy link
Member Author

Fil commented May 23, 2019

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 triangles, and a hull consisting of the non-duplicate points, ordered along an arbitrary vector (for instance the normal to the two first non identical points, if there are >= 2 of them).

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.

@Fil
Copy link
Member Author

Fil commented May 24, 2019

New code, much cleaner. Updated the tests at https://observablehq.com/d/5e4da35146afd543.
I'll need to rebase and clean the whole thing, but that will be later.

Needs this change to Delaunator: https://github.com/Fil/delaunator/commit/b96802021867a788c2c2111085562a086996b52c

Fil added 6 commits May 24, 2019 13:04
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
@Fil
Copy link
Member Author

Fil commented May 24, 2019

Superseded by #64.

@Fil Fil closed this May 24, 2019
@Fil Fil deleted the robust branch May 24, 2019 14:02
mourner pushed a commit to mapbox/delaunator that referenced this pull request Jun 14, 2019
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants