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

Final edge in VoronoiSite.ClockwiseCell is randomly backwards #6

Open
adamgit opened this issue May 5, 2024 · 3 comments
Open

Final edge in VoronoiSite.ClockwiseCell is randomly backwards #6

adamgit opened this issue May 5, 2024 · 3 comments

Comments

@adamgit
Copy link

adamgit commented May 5, 2024

Approx 50/50 chance of this happening, that when requesting .ClockwiseCell, the Edge instances I get are all correct except the final one, where Start and End are reversed.

Guess: the code for ClockwiseCell has an out-by-1 error and is failing to reverse the final edge, so its a matter of luck whether the edge was already clockwise before the conversion took place.

@adamgit
Copy link
Author

adamgit commented May 5, 2024

Correction: it's all edges, I misunderstood the .ClockwiseCell - it doesn't supply the edges in clockwise winding, it supplies them in the order as if they were clockwise, but their directions are still random. Need a second pass to fix their directions to give an actual winding.

@RudyTheDev
Copy link
Owner

Ah, I see. I was wondering what sort of edge case I was missing because I check ClockwiseCell in unit tests extensively.

But yes, ClockwiseCell returns the edges in an order where one follows the other logically, but does not guarantee any order for each edge's start/end points. I guess the simplest explanation is to think what direction is the middle line supposed to go to be considered clockwise for both cases:

clockwise

You can see that "clockwise" actually depends on the edge's position relative to the cell. And I can't really change start/end points once they are assigned.

You are probably wanting to use ClockwisePoints if you are trying to wind around the cell.

May be there is a nicer way I could be returning this, although I am not really sure. I guess I haven't implemented getting edges from a point yet, so following along points doesn't let you "look back" at the edges.

@adamgit
Copy link
Author

adamgit commented May 6, 2024 via email

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

No branches or pull requests

2 participants