What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way? -
ive got bunch of rectangular objects need pack smallest space possible (the dimensions of space should powers of two).
i'm aware of various packing algorithms pack items possible given space, in case need algorithm work out how large space should well.
eg ive got following rectangles
- 128*32
- 128*64
- 64*32
- 64*32
they can packed 128*128 space
_________________ |128*32 | |________________| |128*64 | | | | | |________________| |64*32 |64*32 | |_______|________|
however if there 160*32 , 64*64 1 need 256*128 space
________________________________ |128*32 |64*64 |64*32 | |________________| |_______| |128*64 | |64*32 | | |_______|_______| | | | |________________|___ | |160*32 | | |____________________|___________|
what algorithms there able pack bunch of rectangles , determine required size container (to power of 2, , within given maximum size each dimension)?
the quick , dirty first pass solution great 1 start with, comparison if nothing else.
greedy placement large small.
put largest rectangle remaining packed area. if can't fit anywhere, place in place extends pack region little possible. repeat until finish smallest rectangle.
it's not perfect @ it's easy , nice baseline. still pack original example perfectly, , give equivalent answer second well.
Comments
Post a Comment