Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
up vote 0 down vote accepted

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}$$

share|cite|improve this answer
Hi, thanks for the response, although it doesn't seem to work for me. I created a test example where I do know the before and after widths and heights and this formula doesn't equate to the known dimensions. – Calender Man Feb 8 '13 at 21:22
@CalenderMan: Found a couple errors. Give it a try. – Ross Millikan Feb 8 '13 at 21:27
Hmm, it gets within 1 when using 60 or 30 degrees but using something like 20 or 15 then it ends up being way out. Really appreciate the help, but I think I'll just try to find a way to not need the width and height. Thanks. – Calender Man Feb 8 '13 at 21:58
@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
Why is s = 5/13? I was just using s = sin of the angle. – Calender Man Feb 8 '13 at 22:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.