How to form a Concave shape out of Convex shapes?

前端 未结 5 1629
故里飘歌
故里飘歌 2021-01-31 23:34

i\'m trying to get around the rule of only being able to form convex shapes in the SFML c++ library.

To do this I\'m planning on testing given vertices,

5条回答
  •  后悔当初
    2021-02-01 00:22

    I assume you have your polygon as a list of point, a very simple way would be to go around your polygon and consider the sequence of triplet of consecutive points (A,B,C).

    Then you just check that at one point det(AB,BC) changes its sign, where

    det(AB,AC) = (x_a-x_b)(yc-yb) - (x_c-x_b)(y_a-y_b)

提交回复
热议问题