Sort point list into polygon

后端 未结 3 1141
别跟我提以往
别跟我提以往 2021-01-23 17:59

I have a set of points. This set of points do define a (non convex) polygon but its not ordered.

Since it\'s not ordered I cannot just draw from point to point to draw

3条回答
  •  囚心锁ツ
    2021-01-23 18:50

    You have to order the points so you walk around the polygon with the interior on your left (or right) as you move from point to point. Convex or concave, this is the correct approach.

    But knowing the points is not sufficient. You have to know the connectivity of each edge segment as well. Knowing that, you can start at any point and walk along the perimeter until you reach the starting point again.

提交回复
热议问题