Concave and Convex Polygon - Turn arbitrary polygon into a convex polygon

后端 未结 4 1340
梦毁少年i
梦毁少年i 2021-02-15 14:47

How can I identify and remove those four RED points drawn in image \"alt

Those four points

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 15:26

    Use a convex hull algorithm (such as the Graham scan), and remove all points that are not part of the resulting convex hull.

    In your example, the convex hull will consist of P1, P2, P3, P5, P7, P8, P9, P11, P12, P13, P14, P15, P16, P18, which are precisely all points except the red ones.


    Note that simply removing those points whose inner angle is greater than 180 will not necessarily result in a convex polygon. Take this polygon for example:

    enter image description here

提交回复
热议问题