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

Robust circumcenters when the hull is collinear #142

Merged
merged 2 commits into from Apr 1, 2023
Merged

Conversation

Fil
Copy link
Member

@Fil Fil commented Mar 25, 2023

The failure reported in #141 came from the fact that the first point of the first triangle belonged to the collinear part of the hull, thus making the circumcenters of degenerate triangles (which need to be "projected to the infinite") go to either side arbitrarily. We want them to go "outwards".

The solution suggested here is to make sure we use a non-collinear reference (which I took to be the barycenter of the hull—could have been something else; but the first point of the first triangle was clearly a wrong bet).

I've reduced the test case to:
points = [[10, 190]].concat(Array.from({length: 7}, (d, i) => [i * 80, (i * 50) / 7]))

before
before

after
after

fixes #141

@Fil Fil requested a review from mbostock March 25, 2023 14:30
@Fil Fil mentioned this pull request Mar 25, 2023
@mbostock
Copy link
Member

This looks like an improvement. 👍 Is there still going to be an issue when all the points are collinear, since in that case the barycenter of the hull will also be collinear?

@Fil
Copy link
Member Author

Fil commented Mar 26, 2023

The case where n>2 points are all aligned is addressed differently: we detect this case in

// check for collinear

and jitter the points.

src/voronoi.js Outdated Show resolved Hide resolved
@mbostock mbostock merged commit 1f99535 into main Apr 1, 2023
1 check passed
@mbostock mbostock deleted the fil/fix-141 branch April 1, 2023 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Odd failure
2 participants