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

  • 0
    @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.2011-07-02

2 Answers 2

5

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

1

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