PDA

View Full Version : [AS3] Intelligent, optimal layout of rectangles?



thudfactor
September 16th, 2008, 11:51 PM
I've been searching all over for pointers to this, but since I'm not even sure what to call it I'm not having much luck.

Given a set of rectangles of different sizes and aspect ratios, I want to be able to arrange these so they nest together into a roughly rectangular region. Something like http://www.wordle.net/ (http://www.wordle.net), although wordle is nesting things around much more complex shapes. I'm happy with just rectangles.

I'm not looking for code here, just a rough idea of what strategy you might use to get something like this done. If there's a common solution for this, what the heck is this kind of problem usually called? Then I can pray to google.

Thanks!

rrh
September 17th, 2008, 01:33 PM
It's similar to what's known as a packing problem, except you can overlap the outside of the container a little bit, and the size of that container is determined by the number and size of rectangles you have.

Tricky.

thudfactor
September 17th, 2008, 02:19 PM
I don't think you really need to overlap the container a bit, if you think of the problem as filling from the center of a space out.

Thanks, RRH -- calling it a "packing problem" led me to this article (http://www.devx.com/dotnet/Article/36005/0/page/5) which I think gives me enough to start with. But if anyone else has and idea, I'd love to hear it.

glosrfc
September 17th, 2008, 07:22 PM
http://www.levitated.net/daily/levBoxFitting.html
http://www.levitated.net/daily/levEmotionFractal.html

thudfactor
September 17th, 2008, 09:42 PM
Very nice, thank you!