algorithmpointsconvex

Choosing points for a 2d Convex Hull


I am making one algorithm a day, and didn't make to finish this one recently.

I have a set of points that i draw, and now I'd like to chose pairs to draw lines between them so that when it's done they will form a convex hull.

My idea was to start from the one that has the lowest y- coordinate, and then go in CCW order, but I am not sure how to write a good algorithm for choosing the pairs.

This question is in fact very simple, it's just me who is a beginner :)


Solution

  • Have you tried using the Graham scan algorithm? It actually uses coordinate-sorting and CW order.