Skip to content

Robust circumcenters when the hull is collinear#142

Merged
mbostock merged 2 commits intomainfrom
fil/fix-141
Apr 1, 2023
Merged

Robust circumcenters when the hull is collinear#142
mbostock merged 2 commits intomainfrom
fil/fix-141

Conversation

@Fil
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/voronoi.js Outdated
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