AnswerBun.com

Distance of two points in a rotated rectangle

Mathematics Asked by Fygo on December 23, 2020

I have a rectangle which I need to rotate (blue rectangle in the image). The rotation origin is a random point somewhere inside of this rectangle (point Z in the image). The rotation is ALWAYS clockwise. Actually, the angle is set as well but that’s not really important.

After the rotation I need to find out the distance between the points A and Z on the x axis and D and Z – on the y axis. So basically I need to find the coordinates of point Z inside the "wrapping" (imaginary) rectangle that would exactly contain the blue rectangle and would not be rotated.

I was trying to translate the rotation center to 0, 0 but I am honestly confused with the swapped axis and the clockwise rotation. How should I go about it?

Any help appreciated! Thanks a lot.enter image description here

One Answer

enter image description here

Since we are interested only in the distances related to the rotation center, nothing changes if we move the rotation center to the origin and consider all the coordinates with respect to that point. So consider a "straight" (meaning, parallel to the $y$-axis) line $AD$, so that $A=(x_0, a_0)$ and $D=(x_0, d_0)$. We rotate this line about the origin and call the new line $A'D'$ with coordinates $A'=(a_x, a_y)$ and $D'=(d_x,d_y)$.

Notice that both points $A$ and $D$ travel the angle $theta$ about the origin. Therefore, it is easy to compute the new coordinates of each point. The standard rotation matrix is $$ R_{text{counter-cw}} = left[ begin{array}{cc} cos theta & -sin{theta} \ sin theta & cos theta end{array} right] $$ but this is defined for counterclockwise rotations. Therefore, we have to just flip the sign of the angle (or take the transpose - these are the same in this case), giving $$ R_{text{cw}} = left[ begin{array}{cc} cos theta & sin{theta} \ -sin theta & cos theta end{array} right] $$ Now, the new coordinates are obtained by matrix multiplication: $$ left( begin{array}{c} a_x \ a_y end{array} right) = R_{text{cw}} left( begin{array}{c} x_0 \ a_0 end{array} right) = left( begin{array}{c} x_0 cos theta + a_0sin theta \ - x_0sin theta + a_0cos theta end{array} right) $$ $$ left( begin{array}{c} d_x \ d_y end{array} right) = R_{text{cw}} left( begin{array}{c} x_0 \ d_0 end{array} right) = left( begin{array}{c} x_0 cos theta + d_0sin theta \ - x_0sin theta + d_0cos theta end{array} right) $$ You wanted the distance in the $x$-direction, so it's easy to just take the absolute values of the $x$-coordinates of these results.

Correct answer by Matti P. on December 23, 2020

Add your own answers!

Related Questions

Ideal of a group

2  Asked on January 26, 2021 by kelalaka

     

Prove that $frac{1}{x+1}$ is positive.

3  Asked on January 26, 2021 by m-choy

 

Is the next map a quotient map?

1  Asked on January 25, 2021 by erika21148

 

Convergence of $int_mathbb{R^n} frac1{x^p}dx$

1  Asked on January 25, 2021 by user854662

 

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP