The length and angle of the longest rectangle of given width that can fit within another rectangle of given width and height

algebra-precalculus

I have a particular engineering challenge that I'd like to solve, namely, given a rectangle of length X and width Y, what is the longest rectangle of width $\omega$ that I can fit inside? Additionally, I'd like to know the angle $\alpha$ of the inner rectangle with respect to the outer one. Here's a simple diagram:

Simple diagram of problem

I believe thus boils down to a system of 2 equations with 2 variables ($\lambda, \alpha$):

$$
X = \omega \cdot sin(\alpha) + \lambda \cdot cos(\alpha) \\
Y = \omega \cdot cos(\alpha) + \lambda \cdot sin(\alpha)
$$

But there's a 3rd equation that pops out too; the sum of the areas of the inner rectangle and the triangles around it must equal the area of the outer rectangle:

$$
X \cdot Y = \omega \cdot \lambda + \omega^2 \cdot cos(\alpha) \cdot sin(\alpha) + \lambda^2 \cdot cos(\alpha) \cdot sin(\alpha)
$$

The variables: $X, Y, \omega$ are given real numbers. I'd like to be able to represent $\lambda$ and $\alpha$ symbolically and independently of one another, if possible.

If I start by isolating $\lambda$ in the first equation, I get:

$$\begin{align}
\lambda \cdot cos(\alpha) &= X – \omega \cdot sin(\alpha) \\
\lambda &= \frac{X-\omega \cdot \sin(\alpha)}{cos(\alpha)}
\end{align}$$

That seems simple enough. Substituting this value in for $\lambda$ in the second equation, I get:

$$
Y = \omega \cdot cos(\alpha) + sin(\alpha) \cdot \left[ \frac{X-\omega \cdot \sin(\alpha)}{cos(\alpha)} \right]
$$

distributing $sin(\alpha)$ and find like denominators:
$$\begin{align}
Y &= \omega \cdot cos(\alpha) + \frac{X \cdot sin(\alpha)}{cos(\alpha)} – \frac{\omega \cdot sin^2(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot cos^2(\alpha)}{cos(\alpha)} + \frac{X \cdot sin(\alpha)}{cos(\alpha)} – \frac{\omega \cdot sin^2(\alpha)}{cos(\alpha)}
\end{align}$$

Re-arrange terms and use a double-angle identity:
$$\begin{align}
Y &= \frac{\omega \cdot cos^2(\alpha) + X \cdot sin(\alpha) – \omega \cdot sin^2(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot \left [ cos^2(\alpha) – sin^2(\alpha) \right ] + X \cdot sin(\alpha)}{cos(\alpha)} \\
Y &= \frac{\omega \cdot cos(2\alpha) + X \cdot sin(\alpha)}{cos(\alpha)}
\end{align}$$

I get stuck here, as I don't really know how to isolate $\alpha$. Any pointers?

EDIT: I added additional context, a diagram and an extra equation.

Best Answer

Write $\cos\alpha=k$ so the equation becomes $$Y=\frac{\omega(2k^2-1)+X\sqrt{1-k^2}}k$$ $$(kY-\omega(2k^2-1))^2=X^2(1-k^2)$$ This leaves a quartic equation in $k$ which can be solved by numerical means, and from there $\alpha$ may be derived.

Related Question