Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

Lets say we have a rectangle with height h and width w. If we rotate it by d degrees, what would be the width and height of the window to display it without any clipping? I mean what is the formula to calculate wh and ww?

enter image description here

share|cite|improve this question
How much trigonometry do you know? Do you know how to calculate the short sides of a right-angled triangle given the length of the hypotenuse and one of the acute angles? That's all you need here (after you split $ww$ and $wh$ into their two parts). – TonyK Jul 2 '11 at 12:16
Looking at the picture, $wh$ would be $w \sin(d) + h \cos(d)$. This holds when $0^\circ \le d \le 90^\circ$. – J. J. Jul 2 '11 at 12:17
@TonyK - Next to none ;) – Majid Fouladpour Jul 2 '11 at 12:18
@J.J. - Thanks. Why don't you put that as an answer? – Majid Fouladpour Jul 2 '11 at 12:21
@Majid: Someone else might, I'm a bit busy. And it's not complete: You got to be careful if $d$ doesn't lie in the range I gave. I suspect there will be four cases. – J. J. Jul 2 '11 at 12:31
up vote 5 down vote accepted

$$ wh(d) = \begin{cases} h \cos(d) + w \sin(d), & \mbox{if} \;\; 0^\circ \le d \le 90^\circ \;\; \mbox{or} \;\; 180^\circ \le d \le 270^\circ \;\; \\ w \cos(d-90) + h \sin(d-90), & \mbox{if} \;\; 90^\circ \le d \le 180^\circ \;\; \mbox{or} \;\; 270^\circ \le d \le 360^\circ \;\; \end{cases} $$

$$ ww(d) = \begin{cases} h \sin(d) + w \cos(d), & \mbox{if} \;\; 0^\circ \le d \le 90^\circ \;\; \mbox{or} \;\; 180^\circ \le d \le 270^\circ \;\; \\ w \sin(d-90) + h \cos(d-90), & \mbox{if} \;\; 90^\circ \le d \le 180^\circ \;\; \mbox{or} \;\; 270^\circ \le d \le 360^\circ \;\; \end{cases} $$

share|cite|improve this answer
Thanks so much. – Majid Fouladpour Jul 2 '11 at 16:19

The solution of Jiri results in negative sizes for angles in the third and fourth quadrant.

This calculation, using the absolute sine and cosine values, works for all angles:

$$ wh(d) = h \; |\cos(d)| + w \; |\sin(d)| $$

$$ ww(d) = h \; |\sin(d)| + w \; |\cos(d)| $$

share|cite|improve this answer

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.