# How to rotate a rectangle inside a rectangle with different scales

I have the following information:

1. A computer-generated Rectangle 1 with width=530 and height=686 and an upper-left-hand origin and positive values going right and down.

2. A computer-generated Rectangle 2 is inside Rectangle 1 with its upper-left-hand corner at (132,51) and width=159 and height=54.

3. When the computer rotates Rectangles 1/2, it results in Rectangle 3, a rectangle with width=787 and height=608

4. I was able to determine by external means that Rectangle 4 (formerly rectangle 2) now has an upper-left-hand-corner of (58,224) and width=63 and height=183.

How can I calculate the coordinates and dimensions of #4 above given only #1, #2, and #3?

Pictures of Rectangles 1/2 and 3/4 are shown below:

• Cannot se the pictures. – Mathew Mahindaratne Jun 10 at 21:44
• Can you repost your pictures of rectangles so readers can see them? – Mathew Mahindaratne Jun 10 at 21:53
• Seems like an interesting question that I would enjoy attacking. However, I am confused. My understanding is that when you rotate Rectangle 1, you are not changing its dimensions, but are merely changing the slope of the lines that represent the borders of the rectangle. However, you state that Rectangle 3, which is the result of rotating Rectangle 1, has different width/height dimensions. Please clarify (in your question, not in the comments), what you intend here. – user2661923 Jun 10 at 22:14
• I clarified the question and reposted the pictures. – RickInWestPalmBeach Jun 11 at 14:37
• Still the question is completely unclear to me, starting at step (3). Sorry. Dit you perhaps mean "transform" instead of "rotate"? – Han de Bruijn Jun 16 at 11:01

This is the original, with $$(p,q)=(132,51)$$ and $$(a,b)=(159,54)$$ within the rectangle $$(w,h)=(530,686)$$.
The new rectangle is $$(W,H)=(787,608)$$. So the scaling in x-direction is $$\,W/h=787/686\,$$ and the scaling in y-direction is $$\,H/w=608/530\,$$, but upon calculation they turn out to be the same, within the required accuracy (= one pixel).
Perform the scaling and round to integer values: $$\begin{cases} P = q \times W/h = 59 & ; & Q = (w-a-p) \times H/w = 274 \\ A = b \times W/h = 62 & ; & B = a \times H/w = 182 \end{cases}$$