Packing rectangles without rotation?

1.6k views Asked by At

Is the algorithm for packing rectangles without rotation?

Maybe implementation in C++?

I found this

and

  • GuillotineBinPack
  • ShelfBinPack
  • SkylineBinPack

But they rotate rectangles.

3

There are 3 answers

0
Micromega On BEST ANSWER

You can sort the boxes by width and then place it into a node of a tree. Then split the tree along the 2 axis. For the next box look for the best fit, I.e. least waste and place the box into the free node. Rinse and repeat until no boxes or node is left. You can look into packing lightmaps with a kd-tree by blackpawn.

0
user2729070 On

You can make your boxes square and ignore rotation after packing. This will waste some space but requires no changes to Guillotine library.

0
Sergey K. On

You can use this small code to pack rectangles:

http://www.flipcode.com/archives/Rectangle_Placement.shtml