# Finding original width and height of AABB

I have a rotated rectangle that I don't know the original width and height of. As the current width and height is just the bounding box encapsulating the rectangle, how would I find the actual width and height? I currently have the rotation, bounds of the bounding box, and the center point. Thanks.

-

If the current bounding box is $A$ wide by $B$ high and the original rectangle is $a$ wide by $b$ high, and the rotation angle is $\theta$, we have $B=b |\cos \theta| +a |\sin \theta|, A=a |\cos \theta|+b |\sin \theta|$. These are two equations in two unknowns. For simplicity, let $c=|\cos \theta|, s=|\sin \theta|$ Then the equations become $A=ac+bs, B=bc+as$ We can use substitution to get $$A=ac+bs \\ B=bc+as \\a=\frac 1c(A-bs)\\B=bc+\frac sc(A-bs) \\b=\frac{B-\frac scA}{c-\frac{s^2}c}\\a=\frac{A-\frac scB}{c-\frac{s^2}c}$$
@CalenderMan: I tried it with $a=13, b=5, s=\frac 5{13}$ and it was exact. Could you give the values that are a problem? –  Ross Millikan Feb 8 '13 at 22:04