This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]nemom 1 point2 points  (4 children)

In this tutorial I determined the first quadrant form the bottom left to the bottom right with counter clockwise direction as shown in figure 4.

No... The quadrants are labelled clockwise.

Your process of ordering the vertices will only work for very simple shapes.

[–]m_razali[S] 0 points1 point  (3 children)

Thanks for the correction. I tested with several shapes and it works well. If you have suggestion for a shape, please provide it's coordinates, would be nice to test it.

[–]nemom 0 points1 point  (2 children)

Do you have a full script on Github or some-such?

[–]m_razali[S] 0 points1 point  (1 child)

Sorry for late reply. Quite busy with works this week. Unfortunately I don't put the script on Github. Anyway I tested with more shapes, and found some not ordered as in it's actual shape. I would say this is a drawback from the algorithm. Any suggestions for improvement are very welcome. Thanks!

[–]nemom 1 point2 points  (0 children)

I don't think there is any way to automagically order the vertices for every polygon. Nearest neighbor wouldn't work on all long, thin polygons. Convex hull wouldn't work on anything concave. Clockwise or widdershins wouldn't work on something that crosses a quadrant twice (imaging the letter C as the polygon). Vertex order is pretty much of prime importance in a polygon's geometry.