Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Algorithm for Rectangle Placement
#1
I'm laying out a webpage with images.

The way I figure, an easy algorithm would be to:
1. sort the images by area largest to smallest.
2. Place the largest image in the top-left corner
3. Move through the other images placing them in the first available top-left corner with the top space as the priority.

The width of the page needs to be fixed, but the height can be infinite.
The rectangles can not be rotated or re-sized.

So here are a set of variables:
PageWidth=940

Rectangles:
A=729600 W=600 H=1216
A=476550 W=450 H=1059
A=292500 W=450 H=650
A=147600 W=300 H=492
A=097800 W=300 H=326
A=072900 W=300 H=243
A=072900 W=300 H=243

I'm not really sure how to get QM to place a rectangle and then move through the rest. I've attached an image that would be the result of the algorithm I described above.

I also would like to know the sizes of rectangles left over so I can fill them with other content.

I'm am definitely open to suggestions for any programs that may do this or other resources.

Thanks,
Jim


Attached Files Image(s)
   
#2
I don't know about the code...but this is showing similar to what I'm trying to do:http://www.flipcode.com/archives/Rectangle_Placement.shtml
#3
Two-dimensional orthogonal strip packing problem where guillotine cuts are not required to arrange a set of oriented rectangular shapes onto a larger rectangle of fixed width and infinite height, while minimizing the overall height of the solution.


Forum Jump:


Users browsing this thread: 1 Guest(s)