문제

If I have the following array structure of polygon vertices (polygons can be both convex and concave):

[ [x = 5, y = 5], [x = 10, y = 10], [x = 3, y = 15], [x = 0, y = 7] ]

I can easily tell if the polygon is clockwise or counter clockwise. But how do I convert it? If I reverse the array, it works for the examples I can think about but does it work for every polygon?

도움이 되었습니까?

해결책

Yes reversing the vertices should work in every case... If the ordered list is a valid polygon (no two edges, defined by adjacent vertices, cross one another, including the edge defined by the last vertex to the first), then reversing the order of the vertices will just change it from clockwise to counter-clockwise, or vice versa.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top