# Finding new coordinates in simple rotation on x-y plane

I have a problem where I want to rotate branch so that one of its sides is on the y-axis and the centre of the branch is moved to (x=0,y=0). I want to know the values of the new rotated coordinates in terms of the original coordinates. See picture below:

Rotating problem

To get yp2* is obvious to me because it's the length of the side but I can't get the other rotated coordinates in terms of the original coordinates.

• Can you rotate your image by $\pi/2$ to read better? – Narasimham Mar 3 '16 at 13:18

If the angles between the three branches are all $2\pi/3$, and the branches that appear to be vertical are vertical, as the drawing suggests, then you're looking at a translation followed by a clockwise rotation by $\pi/3$ radians.

You ought to just write out that transformation, and then you will know the destination of any point.

The translation alone is $\left[\begin{smallmatrix}x\\y\end{smallmatrix}\right]\mapsto \left[\begin{smallmatrix}x-x_{p1}\\y-y_{p1}\end{smallmatrix}\right]$.

The rotation is $\left[\begin{smallmatrix}x\\y\end{smallmatrix}\right]\mapsto \left[\begin{smallmatrix}\frac12 &\frac{\sqrt{3}}{2}\\ -\frac{\sqrt{3}}{2}&\frac12\end{smallmatrix}\right]\left[\begin{smallmatrix}x\\y\end{smallmatrix}\right]$. If you don't recognize how I'm getting a rotation matrix with an angle, you really ought to google the topic.

Compose these two transformations, and you have a mapping from old points to new points.

If the angles are not as they appear, then the procedure is the same, you just have to deduce the angle of rotation for the rotation matrix. By simple trigonometry on the branch getting rotated downward, the angle is $\arccos\left(\frac{x_{p2}}{\sqrt{x_{p2}^2+y_{p2}^2}}\right)$.

• No the angles aren't necessarily pi/3. They can be any angles. – piccolo Mar 3 '16 at 11:39
• @user2443944 I added the obvious modification for that case. – rschwieb Mar 3 '16 at 12:03
• If I'm using the anticlockwise rotation matrix would there be a minus sign in? – piccolo Mar 3 '16 at 13:16
• A clockwise rotation by a positive angle $\theta$ would look like $\begin{bmatrix}\cos(\theta)&\sin(\theta)\\ -\sin(\theta)&\cos(\theta)\end{bmatrix}$. To go the opposite direction, it looks like $\begin{bmatrix}\cos(\theta)&-\sin(\theta)\\ \sin(\theta)&\cos(\theta)\end{bmatrix}$. You can rotate either way, you'll just have to adjust the sign of the angle. – rschwieb Mar 3 '16 at 14:00

rschwieb makes a good point describing with matrix multiplication, if you are well versed in matrices and vectors you can even write the whole thing together as a composition of two linear operators by matrix multiplication of a representation of affine transformations on the vector ${\bf v} = [x,y,1]^T$:

First out is the translation which we call $\bf G_T$: $${\bf G_T} = \left[\begin{array}{rrr} 1 & 0 & -x_{pl} \\ 0 & 1 & -y_{pl} \\ 0& 0&1 \end{array}\right]$$ Now for our rotation which we call $\bf{G_R}$ (compare this to the other answer, it is very similar!) $${\bf G_R} = \left[\begin{array}{rrr} \frac{1}{2} & \frac{\sqrt{3}}{2} & 0 \\ -\frac{\sqrt{3}}{2} & \frac{1}{2} & 0 \\ 0& 0& 1 \end{array}\right]$$

So everything together becomes $${\bf G_R} {\bf G_T} {\bf v}$$

This way of thinking may seem a bit overkill for this example but is useful if you want to do more complicated things later. To systematically build up expressions.