views:

176

answers:

2

I have a set of rectangles with their corresponding positions and a big rectangle which serves as the 'bounding box' for these rectangles.

I would like to know of an algorithm that would 'distribute the free space' evenly among the rectangles. Some of you may be familiar with the Distribute Spacing option in Adobe InDesign and similar layout-oriented apps. That would be what I'm looking for.

I did try looking it up, but I'm not familiar with 'graphical' algorithms terminology and trying only terms relating to 'distribute' mainly yields results about Distributed Computing. So, even the names of the algorithms or better terms to look up would be a big help.

Finally, the algorithm doesn't need to be rigorously the same as InDesign's one: pretty much any algorithm that 'distributes' objects inside a region will work fine. In fact, since I'm striving for visual appeal mainly, the more suggestions the better. =D

+1  A: 

You could look into graph layout algorithms. A force-based algorithm might work for you.

Thomas
Interesting links! I might try them, but I'm still interested in the InDesign-like one.
Rafael Almeida
A: 

I'm thinking there must be a way to formulate this as a linear programming problem. maximize the total area of the rectangles, but make sure that they never intersect as being the restrictions. I can't think of anything non-linear here, so should work. The only thing I'm not sure about is if it's possible to generate a list of restrictions to prevent rectangles from overlapping. I can't prove to myself that it is either possible or not not possible...that's the only thing I can think of. Hope it helps.

Chris H
Interesting take on the problem, but it's worth to notice (specially for those not familiar with layout apps) that the Distribute Spacing feature might make the elements overlap, and this would NOT be a problem.
Rafael Almeida
well then you could change the restrictions to control some overlap. (but it would have to be a linear overlap function) There is also non-linear programming if you wanted the overlap to be some non-linear function. IE: pixels allowed to be hidden = sqrt(totalPixels)...I dunno. I just picked that off the top of my head. There are many free linear and nonlinear solvers out there.
Chris H