1. ## Filling an area

I'm trying to fill an area with objects, but I can't seem to wrap my brain around the problem well enough to find a solution. Here is the problem:

I need to fill a trapezoidal area with rows of rectangular objects, laid end-to-end lengthwise. The rows need to be separated by a distance "D". If the rectangular objects have a length "L" and a width "W", and I need to use exactly "N" number of objects, how do I determine the maximum distance "D" to space the rows out?

2. ## Re: Filling an area

You need more information, like the height of the trapezoid and the length of the bases. Is the height $h$ and the bases $b_1,b_2$?

3. ## Re: Filling an area

I have measurements of all parts, but I want to keep the formula generic because I actually have two trapezoids to fill. For now, I just want to use h, b1 and b2 for the basic dimensions of the trapezoid.

I'm pretty sure that gives me enough information to solve the problem, but I could be wrong.

4. ## Re: Filling an area

$\dfrac{h}{W+D}$ gives the number of rows you will have. Assuming $b_1$ is the longer base and $b_2$ is the shorter one, then the maximum number of rectangles you can have in a single row is given by $\left\lfloor \dfrac{\dfrac{h-W}{h}b_1 + \dfrac{W}{h}b_2}{L} \right\rfloor$. If $N$ is less than that, then $D = h-W$. If $N$ is greater than that, then you need another row. Assuming all rows have equal spacing, then place the second row so that a third row will not fit, but maximizes the space between itself and the first row already placed. Keep going until all rectangles are placed.

5. ## Re: Filling an area

I don't think that's quite what I'm looking for. It might help if I introduce another variable. Let's call the number of rows "R". Now D=(h-R*W)/(R-1), where R-1 represents the number of spaces.

Does that make sense?