[Math] Axis aligned rectangle inscribed in rotated rectangle

geometry

I start with an axis aligned rectangle, $R$, that I rotate by the angle $\theta$ to get $R'$.

Afterwards I'd like to identify another axis aligned rectangle, $P$ with the following additional constraints:

  1. The center of $P$ should be at the center of $R'$ (and $R$)
  2. All points inside $P$ should also be inside $R'$
  3. $P$ should be as big as possible, area wise

What is the width and height of $P$, in terms of the width and height of $R$ and $\theta$?

I'm not sure if these criteria uniquely identify a rectangle. If they do not, please enlighten me 🙂


I've attempted applying my brain to the problem, but it appears I am enough out of practice that this is too hard. Hence this cry for help 😉

I've found a related question that seems to be the same question, but the answer is for another question: Rectangle in rotated bounding rectangle

I think I've also found the same question on stack overflow, but the answers are messy, and the ones I've managed to read and put into practice turn out to be wrong: https://stackoverflow.com/questions/5789239/calculate-largest-rectangle-in-a-rotated-rectangle

Best Answer

Let $(\pm x,\pm y)$ be the coordinate of the vertices of $P$. The area of $P$ is $4xy$. At least one of the vertices of $P$ must lie on an edge of $R'$ (otherwise you can increase $P$ by a scaling) and hence also the opposite vertex is on the opposide edge of $R'$. Suppose $(x,y)$ is on one edge of $R'$ and suppose that the edge of $R'$ is contained in the line $ax+by=c$. Then, if $(x,y)$ is internal to the edge, you can apply the Lagrange multipliers to find that $(y,x)=\lambda(a,b)$ which together with the condition $ax+by=c$ gives the coordinates of the vertex: $$ \begin{cases} x = \frac{2c}{a}\\\\ y = \frac{2c}{b}\\ \end{cases} $$

You must try this solution with both edges of $R'$ and discard the solution where the other vertices are outside $R'$.

Related Question