TITLE: Get bounding rectangle segments of a rotated rectangle (matrix?)
QUESTION [5 upvotes]: My problem:
I have: $x$, $y$ & $\alpha$ and the aspect ratio $o$(long):$p$(short) (red rectangle)
I want to have $n$ & $m$ in dependancy of $x, y, \alpha, o, p$

I tried to figure it out with cos, sin and tan but I don't get a solution. My math teacher said something about the matrix  of rotation, but I don't know this method.
I'm also fine with the points where the red corners are on the black rectangle.
Is this possible ?

Thanks in advance ;)

REPLY [2 votes]: Let $z$ be the length of the hypotenuse of the top left right-angled triangle whose two sides are $m$ and $n$. Then $z$ is the length of one side of the red rectangle. Let the length of the other side be $kz$. If we don't know which side is longer in advance, we don't know whether $k$ is equal to $\frac po$ or $\frac op$. However, we do have
$$
\begin{cases}
z\sin\alpha + kz\cos\alpha = x,\tag{1}\\
z\cos\alpha + kz\sin\alpha = y.
\end{cases}
$$
Hence we can determine $k$ without using $o$ or $p$:
$$
k = \frac{y\sin\alpha - x\cos\alpha}{x\sin\alpha - y\cos\alpha}.\tag{2}
$$
Now, from $(1)$, we get
$$
z = \frac x{\sin\alpha + k\cos\alpha}.
$$
Therefore
$$
\begin{align}
n &= z\sin\alpha = \frac{x\sin\alpha}{\sin\alpha + k\cos\alpha},\\
m &= z\cos\alpha = \frac{x\cos\alpha}{\sin\alpha + k\cos\alpha}.
\end{align}
$$