How do I calculate the new position of a given rectangle after subjecting it to rotation and scaling?

630 Views Asked by At

I want to calculate the new position of a modified version of a given rectangle.

  1. The given rectangle is shown in Yellow.
  2. The rectangle undergoing rotation and scaling is shown in Red.

Step-1: The known coordinates of the Yellow rectangle are given in image below.

X = -39, Y = 501, Width = 843, Height = 181, Center X = 383, Center Y = 592

enter image description here

Step-2: I start by rotating the given rectangle $\bf{45^o}$ counterclockwise about its center.

enter image description here

Step-3: Now, I am decreasing its width and increasing its height while holding its top and left edges in place.

Width = 639, Height = 284

enter image description here

Step-4: Finally, the scaled rectangle is rotated clockwise by $\bf{45^o}$ about its new center.

enter image description here

I want to determine the Cartesian coordinates of the top-left corner and the center of the modified rectangle.

enter image description here

1

There are 1 best solutions below

0
On

One way is, just apply the rules for each transformation to each point, starting at the beginning and continuing until you are finished.

However, in this particular case there are some simplifying observations. First, the rotations do not move the center of the rectangle. The center moves only during the "rescaling" operation. For every unit the width increases, the center moves $\frac12$ unit in the diagonal direction toward the upper right. For every unit the height increases, the center moves $\frac12$ unit in the diagonal direction toward the lower right.

Since you apparently have the $x$ axis to the right and the $y$ axis downward, a unit vector toward the upper right is $\left(\sqrt2/2, -\sqrt2/2\right)$ and a unit vector toward the lower right is $\left(\sqrt2/2, \sqrt2/2\right)$.

At the end, once you determine the position of the center, you can use the new height and width to determine the upper left corner.


As an aside, in regular coordinate geometry the height of an axis-parallel rectangle would be exactly twice the difference between the $y$ coordinates of one corner and the center, whereas you have $2(592 - 501) = 182 \neq 181,$ so there is some unusual arithmetic going on in how you define your objects.