Jump to content
  • Advertisement
Sign in to follow this  
Helstorm

Distributing Rectangles in a 2D Canvas

This topic is 3022 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. =)

Share this post


Link to post
Share on other sites
Advertisement
'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'.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!