# Transform a point into another coordinate system

I have the following coordinate systems:

$$x= \begin{pmatrix} 1\\ 0\\ \end{pmatrix}\quad y= \begin{pmatrix} 0\\ 1\\ \end{pmatrix}$$

and:

$$u= \begin{pmatrix} 1\\ 1\\ \end{pmatrix}\quad v= \begin{pmatrix} -1\\ 1\\ \end{pmatrix}$$

$u$ and $v$ are in the $xy$ coordinate system and I have the point $P_{xy} = \begin{pmatrix} -1\\ 0.5\\ \end{pmatrix}$.

I want to move point $P_{xy}$ in the $uv$ coordinate system. Our professor gave us the following formula to calculate $P_{uv}$.

$$\begin{pmatrix} P_u\\ P_v\\ \end{pmatrix}=\begin{pmatrix} u_x & u_y \\ v_x & v_y\\ \end{pmatrix}\begin{pmatrix} P_x\\ P_y\\ \end{pmatrix}$$

But I get the following output for $P_{uv}= \begin{pmatrix} -0.5\\ 0.5\\ \end{pmatrix}$. And I don't think that this is correct.

Now I have my own ideas how to do this. For example I could rotate $u$ and $v$ so that they align with $x$ and $y$. Then I rotate the point with the same amount. I also think that I can use the dot product for this.

But the formula from above looks really neat, I just want to make sure that it is correct?

-
Are you sure you mean $x=\begin{pmatrix}0\\1\end{pmatrix}$ and $y=\begin{pmatrix}1\\0\end{pmatrix}$? They would almost always be named the other way round. –  Matthew Pressland Mar 6 '13 at 21:26
Yes thanks, I accidentally swapped x and y :( –  Maik Klein Mar 6 '13 at 21:38
@Malik I have updated my answer accordingly. –  Matthew Pressland Mar 6 '13 at 21:40

Note that a point $(a,b)$ in the $x-y$ (or the $\begin{pmatrix} 1 \\ 0 \end{pmatrix}$- $\begin{pmatrix} 0 \\ 1 \end{pmatrix}$) co-ordinate system is just $\begin{pmatrix} 1 \\ 0 \end{pmatrix}a+\begin{pmatrix} 0 \\ 1 \end{pmatrix}b$.

To check your answer in the $u-v$ system ($\begin{pmatrix} 1 \\ 1 \end{pmatrix}$- $\begin{pmatrix} -1 \\ 1 \end{pmatrix}$): The point $P_{uv}$ is $-0.5\begin{pmatrix} 1 \\ 1 \end{pmatrix}+0.5\begin{pmatrix} -1 \\ 1 \end{pmatrix}$. Is this equal to $\begin{pmatrix} -1 \\ 0.5 \end{pmatrix}$?

-

The formula you should have is:

$$\begin{pmatrix}P_u\\P_v\end{pmatrix}=\begin{pmatrix}x_u&y_u\\x_v&y_v\end{pmatrix}\begin{pmatrix}P_x\\P_y\end{pmatrix}$$

As we have $u=x+y$ and $v=x-y$, we have $x=\frac{1}{2}(u+v)$ and $y=\frac{1}{2}(u-v)$, so this formula becomes:

$$\begin{pmatrix}P_u\\P_v\end{pmatrix}=\begin{pmatrix}0.5&0.5\\0.5&-0.5\end{pmatrix}\begin{pmatrix}P_x\\P_y\end{pmatrix}$$

If you work out what $P_u$ and $P_v$ are from this formula, you should be able to verify that $P_{xy}=P_uu+P_vv$.

-

The derivation is quite simple. Coordinates of the vector $OP$ in $xy$ system is $$OP_{xy}=P_x x+P_yy$$ At the same time $OP$ has coordinates in $uv$ system $$OP_{uv} = P_uu+P_vv$$ but $u$ and $v$ are also some vectors in $xy$, so $$u = u_xx+u_yy \\ v = v_xx+v_yy$$ Substitute it back to $P_{uv}$ decomposition so you'll get $OP_{xy}$ $$OP_{xy} = P_u(u_xx+u_yy)+P_v(v_xx+v_yy) = (P_uu_x+P_vv_x)x+(P_uu_y+P_vv_y)y$$ from which you can match corresponding components $$P_x = P_u u_x+P_vv_x \\ P_y = P_u u_y+P_vv_y$$ or $$\left ( \begin{array}{cc} P_x \\ P_y \end{array}\right) = \left ( \begin{array}{cc} u_x & v_x \\ u_y & v_y \end{array}\right ) \left ( \begin{array}{c} P_u \\ P_v \end{array}\right )$$ So all you have to do is invert transformation matrix to get $P_{uv}$ components $$\left ( \begin{array}{cc} P_u \\ P_v \end{array}\right) = \left ( \begin{array}{cc} u_x & v_x \\ u_y & v_y \end{array}\right )^{-1} \left ( \begin{array}{c} P_x \\ P_y \end{array}\right )$$ Of course, under the condition that transformation matrix is invertible.

-