I am looking for an algorithm that can help distribute different sized rectangles within a larger rectangle while minimizing overlapping.
I have looked at bin packing algorithms, but they seem to minimize the amount of space between rectangles (in my case the all of the items being packed will be squares).
I guess I want to maximize the distance between all squares and the border of the outer rectangle.
Here is an example of what I am trying to do:
What if you packed them as tightly as possible, using an algorithm like the one described here, then expanded evenly to match the target enclosing rectangle?
For example, say you can pack the 3 rectangles above into a 3x2
box, and your outer box is 7x5
. Then take the vector from the center of the box to the center to each rectangle, and multiply the x component by (7/3)
, and the y component by (5/2
), and that gives the new center.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With