7
$\begingroup$

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

$\endgroup$
5
  • $\begingroup$ 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). $\endgroup$
    – TonyK
    Commented Jul 2, 2011 at 12:16
  • 2
    $\begingroup$ Looking at the picture, $wh$ would be $w \sin(d) + h \cos(d)$. This holds when $0^\circ \le d \le 90^\circ$. $\endgroup$
    – J. J.
    Commented Jul 2, 2011 at 12:17
  • $\begingroup$ @TonyK - Next to none ;) $\endgroup$ Commented Jul 2, 2011 at 12:18
  • $\begingroup$ @J.J. - Thanks. Why don't you put that as an answer? $\endgroup$ Commented Jul 2, 2011 at 12:21
  • $\begingroup$ @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. $\endgroup$
    – J. J.
    Commented Jul 2, 2011 at 12:31

2 Answers 2

5
$\begingroup$

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

$\endgroup$
0
1
$\begingroup$

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

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .