Take the 2-minute tour ×
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.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
what about the position of new rectangle? E, F, G and H Points, their position relative to ABCD? –  Faisal Hafeez Jun 28 '13 at 4:55
    
@FaisalHafeez See my edit. –  RicardoCruz Jun 28 '13 at 19:01

Your Answer

 
discard

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.