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

Reversed the order in which random polygon points are generated to satisfy the right hand rule #2715

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smallsaucepan
Copy link
Member

Resolves #2605.

…tisfy to the right hand rule for polygons. Resolves Turfjs#2605
vertexToCoordinate(randomPositionUnchecked(paddedBbox))
);
vertices = vertices
.reverse() // Make counter-clockwise to adhere to right hand rule.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seem fine to do in the module's current state, but the performance of the module with all of the array.map() calls seems like it'd probably be easy to make quite a bit faster. If we went to that trouble we'd probably want to just make vertices just populate in the reverse order so that it was correct without the reversing step here.

Happy to merge this as is, because I haven't heard of any performance-sensitive random polygon generation hitting issues here, and this reads clearly in its current form.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look and see if there's a way to avoid reverse() ...

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

Successfully merging this pull request may close these issues.

Randomly generated polygons do not comply with the right-hand rule.
2 participants