# Calculate width and height to give to rectangle to achieve required size after rotation

My goal is to create a rotated rectangle with a size to my specification. I begin with a regular rectangle which gets rotated 45 degrees.

Now I know I have succeeded to calculate the width and height after the rotation using;

rotatedSize = (sin(0.785398163) * originalSize) * 2;


So when I want a rotated rectangle of 100x100 my formula is;

100 = (sin(0.785398163) * originalSize) * 2;


Now I am not very good at math but I know there is a way to solve this formula, can anyone assist me in solving it?

-

You need $\sin \frac{\pi}{4}=\frac{\sqrt{2}}{2}\approx 0.707\$, so originalsize$=\frac{100}{\sqrt{2}}\approx 70.71$

-

Solving for $\text{originalSize}$ can be done by division: $$\text{originalSize}=\frac{100}{2*\sin(0.785398163)}.$$

This is because your formula really says that $$100=(\text{originalSize})*(2*\sin(0.785398163))$$ (I gathered together the two numbers that $\text{originalSize}$ was multiplied by to get $100$.)

For the particular angle $\pi/4$ that we are looking at, the sine is exactly $1/\sqrt{2}$, so the bottom simplifies to $\sqrt{2}$. And then a little further manipulation (multiply top and bottom by $\sqrt{2}$) yields $50\sqrt{2}$. To the limit of precision of my calculator, this is $70.710678$.

-
Andre, could you explain this answer a bit more for people searching for this? Where does the 2 come from and why? It seems the above Is there a more general formula to get original width and height of any sized rectangle? – Simon Sarris Aug 29 '11 at 20:52
@Simon Harris: It might be interesting for graphics programmers to know how we get the formula for space occupied when an $a\times b$ "horizontal/vertical" rectangle is rotated by $\theta$. However, that's not the question that was asked here, what was asked was basic algebra. If I answered here a question that wasn't asked, the result would be buried. I suggest that you post the relevant question, in whatever level of generality you wish, including specification of centre of rotation. There will be answers, including mine if I am quick enough! – André Nicolas Aug 29 '11 at 22:11
Okay, I have posted the (somewhat related) question: math.stackexchange.com/questions/60718/… – Simon Sarris Aug 30 '11 at 14:11
@Simon Harris: And, as promised, I have posted an answer. Naturally, I was not first to post an answer. But on seeing the other answer, I decided that mine was different enough (though roughly equivalent) to be worth posting. – André Nicolas Aug 30 '11 at 15:23