View Full Version : How many rectangles fit in a triangle?
benbenny
May9-11, 10:21 AM
Does anyone know how one could calculate the maximum number of whole rectangles that can fit into a triangle.
Say you know the length of the sides of the triangle (t1,t2,t3) and the of the sides of the rectangle (r1,r2).
Thanks.
What's the application? Are there any other restrictions that would make it easier?
benbenny
May10-11, 08:20 AM
Ive come up with this so far. It only allows to fit the rectangles in portrait or landscape mode, not a combination of both, nor diagonally.
Any triangle can be made into two right triangles (I think).
A given right triangle has bases t1,t2, and hypotenuse t3.
The number of rectangles (r1,r2) that can fit in the first row in the triangle is
N = \downarrow \frac{[(t1-r1)\frac{t2}{t1}]}{r1}
(down arrow denotes rounding down to nearest integer)
The total number of rectangles that can fit in the triangle is then:
N = \Sigma_{n=1} \downarrow \frac{[(t1-nr1)\frac{t2}{t1}]}{r1}
where the sum is from n=1 until the outcome of the expression is zero (I don't know how to denote this mathematically).
This needs to be done twice, the second time you switch between r1 and r2, to find out if landscape or portrait offers the bigger solution.
That'd be a nice way if you could prove that they will all be stacked in the same orientation as each other. And allow them to straddle t2.
It seems intuitive that every rectangle should have one side collinear with a side of the triangle or another rectangle, and should be slid up against a side of something. So maybe you can do it with a recursive algorithm that tries every possible position of each new rectangle being added - that won't be too many because there's only a finite number of sides for them to be parallel with, and only a couple of positions along those sides.
benbenny
May10-11, 11:36 AM
What do you mean by "straddle t2"?
Thanks for the input!
I mean one side of the rectangle is on each side of the perpendicular line (which I think you called t2) that cuts the triangle in two. It seems like your formulae require all rectangles to be butted up against this line.
By the way "floor" and "cieling" functions force rounding down/up. \left\lfloor 3.4 \right\rfloor \left\lceil 3.4 \right\rceil
benbenny
May26-11, 12:18 PM
Ok, so here is one way to do it that gets rid of the straddling assumption. But it does not get rid of the same orientation assumption.
If the triangle sides are a,b,c. The number of rectangles that can fit would be
\Sigma_{n=1} \downarrow\frac{d_{n}}{R_{2}}
where
d_n = a - ( \frac{nR_1}{tan(arccos(\frac{-c^2 +a^2+b^2}{2ab}))}+ \frac{nR_1}{tan(arccos(\frac{-b^2 +a^2+c^2}{2ac}))})
Now you have to rotate a-->b b-->c c-->a carry out the calculation again, than rotate again and do it again. You also need to do it twice with R1<-->R2 for every rotation. In total this gives 18 calculations and the biggest figure is the max number of whole rectanlges that can fit.
Its not the most elegant way of doing it, but you can apply it in excel to get quick results.
I havent tested it yet, so although Im pretty sure about the principle of it, there may be a math error.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.