From: Benjamin Root [mailto:ben.root@ou.edu]
Sent: Friday, August 19, 2011 13:43
 
I have an arbitrary list of coordinates that I know represent the boundary of a polygon.  Is there some sort of function from the contouring or path codes that would allow me to pass in that list and get back the resorted list with the path codes with it?

Hi, Ben. Is it the order of the points around the polygon that is unknown, and is it unambiguous because the polygon is known to be convex? If so, I believe you could use part of the Graham scan [1] convex hull algorithm. The function you need would find the point P with the lowest Y coordinate, then sort the remaining points by the cosine of the angle they and P make with the X axis. After that, the list comprising P and the sorted points would need the path codes.

If the polygon is concave but the order is somehow clear (e.g., a radial progression about the average coordinate), you might be able to adapt the method. I hope I understood your problem correctly and that this helps.

[1] http://en.wikipedia.org/wiki/Graham_scan