Efficient Packing Algorithm for Irregular Polygons

前端 未结 2 1737
你的背包
你的背包 2021-02-04 12:16

I\'m looking for a packing algorithm which will reduce an irregular polygon into rectangles and right triangles. The algorithm should attempt to use as few such shapes as possib

2条回答
  •  误落风尘
    2021-02-04 13:09

    I wish I had time to play with this, because it sounds like a really fun problem!

    My first thought (from looking at your diagram above) would be to look for 2 adjacent right angles turning the same direction. I'm sure that won't catch every case where a rectangle will help, but from a user's point of view, it's an obvious case (square corners on the outside = this ought to be a rectangle).

    Once you've found an adjacent pair of right angles, take the length of the shorter leg, and there's one rectangle. Subtract this from the polygon left to tile, and repeat. When there's no more obvious external rectangles to remove, then do your normal tiling thing (Peter's answer sounds great) on that.

    Disclaimer: I'm no expert on this, and I haven't even tried it...

提交回复
热议问题