Reversed the order in which random polygon points are generated to satisfy the right hand rule#2715
Conversation
…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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Let me take a look and see if there's a way to avoid reverse() ...
There was a problem hiding this comment.
Some performance results. Ops/sec for a 100000 vertex random polygon, average of three runs:
| Original | reverse() |
|---|---|
| 47.98 | 46.75 |
Agree with you - the added code complexity isn't worth it. Will merge.
Resolves #2605.