   Distributing Rectangles in a 2D Canvas
  Hi all,I need to distribute axis-parallel rectangles with different widths and heights on a 2-dimensional canvas. The requirements are:1. None of the rectangles may intersect with another rectangle, nor be placed beyond the canvas, i.e., the rectangles are bounded by the canvas;2. Distribute as many rectangles as possible, i.e., minimize `free' space that are not occupied by any rectangles.So my problem is to find an algorithm that computes the positions of the rectangles given the widths and heights of the rectangles and the canvas. I'm thinking about linear programming here, but just can't get my head around it.Any suggestion and/or direction is appreciated. =)   
  'Bin packing' is the term you're looking for. There are lots of references available on this, so try searching the forums and/or internet for (e.g.) 'bin packing', 'texture atlas', or 'lightmap packing'.   