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?

Thanks in advance.