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

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

## Related Questions

### Show $log{a_n}rightarrowlog{a}$ as ${nrightarrowinfty}$

1  Asked on January 27, 2021 by smejak

### Determine whether a set is Invariant, Positively invariant or negatively invariant

1  Asked on January 27, 2021 by bernard-mathews

### Upper bound for the total curvature of a shortest path in the boundary of a convex polyhedron in $mathbb{R}^3$.

1  Asked on January 27, 2021 by hk-lee

### Sum of all solvable ideals of a Lie algebra and radical

1  Asked on January 26, 2021

### Let $f: (mathbb{Z}_{24}, +) rightarrow (mathbb{Z}_{36}, +)$ be a group homomorphism. How many elements are there in the kernel of $f$?

2  Asked on January 26, 2021 by user828643

### Ideal of a group

2  Asked on January 26, 2021 by kelalaka

### It does not say that A and B is mutually inclusive, so p(AUB) is between 1/2 and 1, right?

2  Asked on January 26, 2021 by t298

### Monodromy element: Why that name?

0  Asked on January 26, 2021

### Algebraic Operations with Summation within summation

1  Asked on January 26, 2021 by rom

### Prove monotone convergence theorem when $int |f_1| dmu < infty$ holds

1  Asked on January 26, 2021 by evan-kim

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

3  Asked on January 26, 2021 by m-choy

### For a projection $Pi$, is $text{tr}(Pi X)leq text{tr}(X)$?

2  Asked on January 26, 2021 by user1936752

### Does the homotopy pullback of a diagram of spaces who are homotopy equivalent to CW-complexes have the homotopy type of a CW complex?

0  Asked on January 26, 2021

### Prove that $f(x)=frac{1}{x}$ is uniformly continuous on $(frac{1}{2},infty)$

1  Asked on January 25, 2021 by siobhan-ren

### Action of a Lie subgroup

0  Asked on January 25, 2021

### Is the next map a quotient map?

1  Asked on January 25, 2021 by erika21148

### Number of iterations to find the root of $x^3+2x-54$ using Newton’s Method

1  Asked on January 25, 2021 by gibbs

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

1  Asked on January 25, 2021 by user854662

### Connection between max and min of symmetric random variables

1  Asked on January 25, 2021 by losleon