we need to organize them in a counter-clockwise fashion:
[1 1]
[1 4]
[4 4]
[4 1]
Oh....and the polygon is not necessarily regular
Is it convex? If yes you might take the convexhull (qhull)
to order them and take the algebra area to see how they are
oriented.
Bruno
Bruno
Another idea that might or might not work depending on the
shape of your polygons is to remove the barycenter of all
vertexes and take the polar-angle (use function atan2, or
transform to complex and use function angle), and sort the
vertexes with respect to angle.
Bruno
If the polygon is not convex, the problem is very ill-
defined, which leads me to think you might want to add
specifics to the problem before this discussion continues.
For example, suppose you have 5 points consisting of the
vertices of a square, plus it's center.
[0 0]
[1 0]
[1 1]
[0 1]
[0.5 0.5]
Notice that I've ordered the square's vertices counter-
clockwise. However, I can now insert [0.5 0.5] anywhere in
the list and still get an counter-clockwise ordering.
Why? because I can build a non-convex polyhedron by
connecting any two adjacent corners of the square to the
center.
"Ahmad " <ahmad...@gmail.com> wrote in message <g6h4un$rs6$1...@fred.mathworks.com>...