How to form a Concave shape out of Convex shapes?

前端 未结 5 1630
故里飘歌
故里飘歌 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:11

    Alright, just to mash all the info together:

    • To test polygon Concaveness, look at this page given by Adrian Taylor
    • One way to accomplish my goal is to use Monotone Decomposition and Triangulation
    • You can learn about Monotone Decomposition at this lovely site: (summary of it below)

    img 1

    • Finally, triangulate the now Monotone shapes using the information in this Powerpoint:

      1. Push u1 and u2 on the stack.
      2. j = 3 /* j is index of current vertex */
      3. u = uj
      4. Case (i): u is adjacent to v1 but not vi. add diagonals uv2, uv3, …, uvi. pop vi, vi-1, …, v1 from stack. push vi, u on stack. Case (ii): u is adjacent to vi but not v1. while i > 1 and angle uvivi-1 <  add diagonal uvi-1 pop vi from stack endwhile push u Case (iii): u adjacent to both v1 and vi. add diagonals uv2, uv3, …, uvi-1. exit
      5. j = j + 1 Go to step 3.

    **Note:**
    By “adjacent” we mean connected by an edge in P.   
    Recall that v1 is the bottom of the stack, vi is the top.    
    By “Push” we mean push the item(s) to the back of the list    
    

    Hope this helps someone... but I'm still looking for any better/faster solutions.

提交回复
热议问题