Geometry – Scaling Two Rectangles to Same Height with Fixed Total Width

algebra-precalculusgeometry

I have two rectangles of different sizes side by side.

I want to scale them both (each maintaining their original aspect ratio) so they each end up with the same height and together equal a specified, fixed width.

I would like to find a formula that will work no matter what the sizes of the rectangles are (some may be bigger than the target width, some may be smaller – thus some will have to be scaled up and some down).

I found what appears to be a very similar question here, however the only solution provided seemed to imply a universal scaling factor. That doesn't work for my situation because the rectangles need independent scaling. I am also only scaling two rectangles instead of three, and the resulting widths of my rectangles must together add up to a specific width (the other question just didn't want to exceed one).

Any help would be incredibly appreciated.

Best Answer

Let $h_1, h_2$ be the heights of the rectangles and $w_1, w_2$ be their widths. Let $w_T$ be the total desired width. We seek scaling constants $c_1, c_2$ such that when the dimensions of the rectangles are multiplied by $c_1$ and $c_2$, respectively, their heights $c_1 h_1$ and $c_2 h_2$ are equal; moreover, their total width $c_1 w_1 + c_2 w_2$ must equal the total desired width $w_T$. Hence we seek the solution to the system of equations $$\begin{align} c_1 w_1 + c_2 w_2 &= w_T, \\ c_1 h_1 &= c_2 h_2. \end{align}$$ The second equation implies $$c_2 = \frac{c_1 h_1}{h_2},$$ so substituting this into the first equation and solving for $c_1$ yields $$c_1 = \frac{w_T}{w_1 + \frac{h_1}{h_2} w_2} = \frac{h_2 w_T}{w_1 h_2 + h_1 w_2}.$$ This in turn implies $$c_2 = \frac{h_2 w_T}{w_1 h_2 + h_1 w_2} \cdot \frac{h_1}{h_2} = \frac{h_1 w_T}{w_1 h_2 + h_1 w_2}.$$ These are the desired scaling factors.

Let us put this result into practice. Suppose the first rectangle has height $h_1 = 5$ and width $w_1 = 3$, and the second rectangle has height $h_2 = 4$ and width $w_2 = 7$. We want the total width to be $w_T = 9$. Then the required scaling factors are $$c_1 = \frac{4(9)}{3(4) + 5(7)} = \frac{36}{47} \approx 0.765957, \quad c_2 = \frac{5(9)}{47} = \frac{45}{47} \approx 0.957447.$$ (Notice the denominators of $c_1$ and $c_2$ are the same.) The resulting scaled rectangles have common height $$c_1 h_1 = c_2 h_2 = \frac{180}{47} \approx 3.82979,$$ and widths $$c_1 w_1 = \frac{108}{47} \approx 2.29787, \quad c_2 w_2 = \frac{315}{47} \approx 6.70213.$$ Their total width is $$c_1 w_1 + c_2 w_2 = \frac{108 + 315}{47} = \frac{423}{47} = 9 = w_T.$$

Related Question