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

Stable order for segment clipping? #38

Merged
merged 6 commits into from
Apr 11, 2018
Merged

Stable order for segment clipping? #38

merged 6 commits into from
Apr 11, 2018

Conversation

mbostock
Copy link
Member

Attempting to fix #37. When clipping the Voronoi cell segments, this orders the segment so that the starting point is inside the clip region, if possible. However, it looks like there’s still a problem with the bottom-left cell for reasons that are unclear to me. 😦

Any chance you could take a look, @mourner?

image

https://beta.observablehq.com/@mbostock/d3-delaunay-bug

@mbostock
Copy link
Member Author

The other problem is that containsFinite / containsInfinite are broken when the circumcenters are near-infinite. Due to limited numerical precision, the cell polygon is no longer guaranteed to be convex. We can workaround that if we’re careful during clipping, but voronoi.contains can’t make the same assumption that the given point x, y is inside the viewport.

But it occurs to me that we could use a strategy similar to voronoi.find to do the containment check, since the definition of the Voronoi cell is that it is the area of the plane closest to its site. Then we wouldn’t even need to compute the Voronoi cell polygon to check containment.

@mbostock mbostock merged commit dd14b97 into master Apr 11, 2018
@mbostock mbostock deleted the voronoi-clip branch April 11, 2018 15:30
@mbostock
Copy link
Member Author

Yay, the new strategy works well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant