Find the scaling factor of a rotated rectangle circumscribing another rectangle of same size

geometrytrigonometry

Suppose rectangle 1 with length $l$, and width $w$, which has a center $C$ (where the diagonals intersect), rectangle 2 with same length $l$, width $w$, and center $C$, but rotated $\theta$ radians across $C$. How do you find the scaling factor $S$ of rectangle 2 around $C$ such that rectangle 2 circumscribes (It won't matter to me if only 2 of the vertices are being touched as long as rectangle 1 is fully inside rectangle 2, and the scaling is done exactly around center $C$.) rectangle 1?

I searched for this question but with squares and the answer was $\sin{\theta}+\cos{\theta}$, but this answer doesn't work with rectangles.enter image description here

Best Answer

Let $a= \ell/2$, let $b = w/2$, and let the coordinates of the center $C$ be $(0,0).$

Let's also keep the $x$ and $y$ axes on the axes of the circumscribed rectangle. That means working in a rotated coordinate system most of the time or considering the inner rectangle to be the one that is rotated. I find the latter simpler to visualize, so let's do that.

Then the upper right corner of the original rectangle is at $(x,y) = (a,b)$. If the rectangle is rotated through an angle $\theta$ counterclockwise, the upper right corner's $y$ coordinate becomes $b \cos \theta + a \sin \theta.$ When $0 < \theta < \frac\pi2,$ the (rotated) upper right corner is the highest point of the rotated rectangle and therefore determines that the $y$-coordinate of the top edge of the circumscribed rectangle must be at least $b \cos \theta + a \sin \theta.$ Since the $y$-coordinate of the unscaled rectangle is $b,$ this implies the rectangle must be scaled up by at least the factor $\cos \theta + \frac ab \sin \theta.$

Similarly, the lower right corner of the original rectangle is at $(x,y)=(a,-b),$ and its $x$ coordinate after rotation becomes $a \cos\theta + b \sin\theta,$ requiring the $x$-coordinate of the right edge of the circumscribed rectangle to be $a \cos\theta + b \sin\theta$ when $0 < \theta < \frac\pi2.$ This implies the rectangle must be scaled up by at least the factor $\cos\theta + \frac ba \sin\theta.$

If $a \geq b$ then the first formula gives a greater scaling factor, that is, the circumscribed rectangle is determined by where its top edge rests on a corner of the rotated rectangle. If $b \geq a$ the circumscribed rectangle is determined by where its right edge touches a corner of the rotated rectangle.

But if we continue to rotate the original rectangle, each corner of the rectangle in turn touches the top edge of the circumscribed rectangle (if $a \geq b$) or the right edge of the circumscribed rectangle (if $b \geq a$). This means the formulas $b \cos\theta + a \sin\theta$ and $a \cos\theta + b \sin\theta$ are repeated with all four possible combinations of signs on $a$ and $b.$ Since the size of the circumscribed rectangle is always determined by which of the four corners is uppermost (if $a \geq b$) or rightmost (if $b \geq a$), we have to consider the worst-case combination of signs at all times. This gives us the formulas $b \lvert\cos\theta\rvert + a \lvert\sin\theta\rvert$ and $a \lvert\cos\theta\rvert + b \lvert\sin\theta\rvert,$ corresponding to the scaling factors $$ \lvert\cos\theta\rvert + \frac ab \lvert\sin\theta\rvert \quad\text{and}\quad \lvert\cos\theta\rvert + \frac ba \lvert\sin\theta\rvert. $$ We have to scale up by whichever factor is larger in order to circumscribe an unrotated rectangle around the rotated rectangle, so the scaling factor works out to $$ \lvert\cos\theta\rvert + \max\left\{\frac ab, \frac ba\right\} \lvert\sin\theta\rvert. $$

Of course if you know in advance that $a \geq b$ (that is, that the length of the rectangle will be greater than its width), you can simplify the formula by replacing $\max\left\{\frac ab, \frac ba\right\}$ by $\frac ab.$

Here is an interactive demonstration of the formula.


Note that for a square, where $a = b,$ the scaling factor that works for all angles of rotation (not just between $0$ and $\frac\pi2$) is $$ \lvert\cos\theta\rvert + \lvert\sin\theta\rvert. $$ Without the absolute values, the factor $\sin\theta + \cos\theta$ decreases to zero when $\theta = \frac34\pi$ and is negative when $\theta = \pi,$ and so is clearly not a correct scaling factor in either of those cases.

Related Question