Get rotation angle of a square from its projection I would like to get your help in solving a problem that looks pretty easy at a glance.
I have a 2D square with unknown side width. The opposite sides of the square have different colors (let's say black/white). The square is rotated and projected onto an axis (see the figure):

The lengths of AB and BC are known. How do I get the rotation angle from the projections?
Actually, I need rather sine and cosine values of the angle.
I need to add that the angle is within the range of $[0, \pi]$, as rotation by $\pi$ makes the same square again.
 A: Assume for the moment that your square had a side length of $1$. Then you can compute the projected lengths as a function of the angle. Your will get $AB=\lvert\cos\theta\rvert$ (length one for two rotation, but length vanishes for right angle) and $BC=\lvert\sin\theta\rvert$ (zero projection for two angle but grows to one at the right angle).
Now your square is of unknown edge length, so the above formulas don't hold individually. But since the scale factor is the same for both edges, the ratio still holds. For $0\le\theta\le\frac\pi2$ where both trigonometric functions are non-negative you get
$$\tan\theta=\frac{\sin\theta}{\cos\theta}=\frac{BC}{AB}$$
You can use the arcus tangens to get the angle. Or you just use that $\sin^2\theta+\cos^2\theta=1$ to scale back to unit length and obtain
$$\sin\theta=\frac{BC}{\sqrt{AB^2+BC^2}}\qquad
\cos\theta=\frac{AB}{\sqrt{AB^2+BC^2}}$$
For $\frac\pi2\lt\theta\lt\pi$ you will need to take signs into account. The cosine will be negative in this case. Also the order of the projected lines will be swapped, which is how you can recognize this case. Of course distinguishing $0$ from $\pi$ will be impossible, so you probably meant the half-open range $[0,\pi)$.
