0

I am trying to write an algorithm that would fill area of 8*2 with rectangles of sizes 2*2, 2*1, 4*2. Do such algorithms have a name? I am looking for an examples. Currently I am little bit lost in loops.

m.s.
  • 16,063
  • 7
  • 53
  • 88
henrijs
  • 1,010
  • 2
  • 11
  • 19
  • [Tesselation](http://en.wikipedia.org/wiki/Tessellation) – Marc B Nov 27 '14 at 15:32
  • I think Bin packing is more suited for this ... look here for example http://stackoverflow.com/a/21282418/2521214 – Spektre Nov 27 '14 at 15:34
  • How about something like tetris from birds view? Does that have a name? Sorry if I sound silly :) Like, there is a map of a grid. – henrijs Nov 27 '14 at 17:55

1 Answers1

0

You can try a treemap. Sort the rectangles by a dimension and save the biggest into a tree. Split the tree on both axis and choose the best free node to store the next rectangle. Rinse and repeat. Bin packing can be harder, for example you can also rotate the rectangles.

Micromega
  • 12,486
  • 7
  • 35
  • 72