4
$\begingroup$

I have a box of height h and width w. I rotate it to r degrees. Now I resize it so that it can original box in it. What will be the size of newly box.

Original Box:

Original Box

Box after rotating some degrees.

enter image description here

New box after rescaling.

enter image description here

So my question is what should be the formula to calculate new size (width, height), position relative to old one.

What I have Width "w", height "h", position (x,y) and angle (t).

$\endgroup$

1 Answer 1

3
$\begingroup$

Assuming the old rectangle inscribed in the new one, we have the following picture:

enter image description here

Let $\theta$ ($0 \leq \theta \leq \frac{\pi}{2}$) the rotation angle, $w'$ the new width and $h'$ the new height, then we have the following equations: $$w' = w \cos \theta + h \sin \theta$$ $$h' = w \sin \theta + h \cos \theta$$

The new rectangle is not similar to the old one, except for $h = w$ when both rectangles are in fact squares.

Edit:

Considering $O$ (the center of both rectangles) as the origin of the coordinate system, the points $E$, $F$, $G$, and $H$ can be calculated by the following equations: $$E=\left(\frac{w}{2}-w \cos^2 \theta,-\frac{h}{2}-w \sin \theta \cos \theta \right)$$ $$F=\left(\frac{w}{2}+h \sin \theta \cos \theta,-\frac{h}{2}+h \sin^2 \theta \right)$$ $$G=\left(-\frac{w}{2}+w \cos^2 \theta,\frac{h}{2}+w \sin \theta \cos \theta \right)$$ $$H=\left(-\frac{w}{2}-h \sin \theta \cos \theta,-\frac{h}{2}+h \cos^2 \theta \right)$$

$\endgroup$
2
  • $\begingroup$ what about the position of new rectangle? E, F, G and H Points, their position relative to ABCD? $\endgroup$
    – fhnaseer
    Commented Jun 28, 2013 at 4:55
  • $\begingroup$ @FaisalHafeez See my edit. $\endgroup$ Commented Jun 28, 2013 at 19:01

You must log in to answer this question.

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