1

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?

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
btatarov
  • 657
  • 1
  • 5
  • 8
  • Can you add a definition of what you mean by a clockwise polygon? – ely Sep 28 '12 at 13:08
  • A polygon that has is vertices ordered clockwise. – btatarov Sep 28 '12 at 13:12
  • Oh, so not the same as here: [(link)](http://paulbourke.net/geometry/clockwise/index.html) (e.g. you're not worried about the sign of adjacent edge cross-products?) – ely Sep 28 '12 at 13:14
  • clockwise means that the "inside" of the polygon is always to the right, and the "outside" is to the left. - counterclockwise, the "inside" is to the left. – Charles Bretana Sep 28 '12 at 14:06

1 Answers1

3

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.

Charles Bretana
  • 143,358
  • 22
  • 150
  • 216