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:

Pictures 1/2

Pictures 3/4

  • $\begingroup$ Cannot se the pictures. $\endgroup$ – Mathew Mahindaratne Jun 10 at 21:44
  • $\begingroup$ Can you repost your pictures of rectangles so readers can see them? $\endgroup$ – Mathew Mahindaratne Jun 10 at 21:53
  • 3
    $\begingroup$ 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. $\endgroup$ – user2661923 Jun 10 at 22:14
  • $\begingroup$ I clarified the question and reposted the pictures. $\endgroup$ – RickInWestPalmBeach Jun 11 at 14:37
  • $\begingroup$ Still the question is completely unclear to me, starting at step (3). Sorry. Dit you perhaps mean "transform" instead of "rotate"? $\endgroup$ – Han de Bruijn Jun 16 at 11:01

Reverse engineering

This is the original, with $(p,q)=(132,51)$ and $(a,b)=(159,54)$ within the rectangle $(w,h)=(530,686)$.

enter image description here

First rotate counterclockwise over 90 degrees:

enter image description here

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

enter image description here

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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.