# How to get the transform the coordinates of a 3D point from the standard basis to another basis?

Suppose I have the coordinates of a point in the standard $\mathbb{R}^3$ basis $B_0 = (\vec{e_0}, \vec{e_1}, \vec{e_2})$, with $\vec{e_0} = (1,0,0)$, $\vec{e_1} = (0,1,0)$ and $\vec{e_2} = (0,0,1)$. Let $B_1 = (\vec{u}, \vec{v}, \vec{w})$ be my target coordinate system and $P_{B_0} = (x, y, z)$ the point I want to get the coordinates of in $B_1$. Could anyone explain to me how to do this? This is what I want to achieve (finding $x'$ and $y'$) but in 3D.

• – ℋolo
Jul 5, 2018 at 15:41
• Yes, I know about that and I even slightly understand how it works. But I'm having trouble making links here for actually solving my problem. Let's take $x$ axis rotation for example: I have my $\vec{u}$ vector which is a rotated $\vec{e_0}$, but I do not know by how much, if that makes any sense. Jul 5, 2018 at 15:45
• To answer the title question, find the coordinate transition matrix. Each standard basis vector is rotated by $\theta$ so need to simply find the image of each of these. Jul 5, 2018 at 15:52
• Yes, you need the angle between the 2 and using the matrix in the link I sent you will get it
– ℋolo
Jul 5, 2018 at 15:55
• I know $\vec{u}$, $\vec{v}$ and $\vec{w}$ (each of their components). Do you think I can find the angle between, say, $\vec{e_0}$ and $\vec{u}$ like so: $arccos(\frac{\vec{e_0} \cdot \vec{u}}{e_0 \cdot u})$? Jul 5, 2018 at 15:58

If you make a matrix $M$ with the basis vectors $u$, $v$ and $w$ as columns. Then you can map from the standard basis to the new one by transforming your vector with $M$.

You can also send vectors from the new basis back to the standard basis by transforming them with $M^{-1}$.

If $M$ happens to be a rotation matrix (as shown in the pictute) then also then $M^T = M^{-1}$

• So all I have to do is to multiply $M$ by the column vector $(x, y, z)$? Because I have $M = (\vec{u}, \vec{v}, \vec{w})$. Jul 5, 2018 at 16:02
• Yes, I think so Jul 5, 2018 at 17:34

Let the new coordinates be $(X,Y,Z)$, so that

$$\vec P=X\vec u+Y\vec v+Z\vec w \\=X(u_x\vec e_0+u_y\vec e_1+u_z\vec e_0)+Y(v_x\vec e_0+v_y\vec e_1+v_z\vec e_0)+Z(w_x\vec e_0+w_y\vec e_1+w_z\vec e_0)$$

at the same time that $$\vec P=x\vec e_0+y\vec e_1+z\vec e_2.$$

By identification,

$$\begin{cases}Xu_x+Yv_x+Zw_x=x, \\Xu_y+Yv_y+Zw_y=y, \\Xu_z+Yv_z+Zw_z=z. \end{cases}$$

Now you can express the new coordinates as a function of the old ones by solving the $3\times3$ system.

After testing my program with a few examples, I might have found the solution based on one of the comments to my original post. I have the standard $\mathbb{R}^3$ basis $B_0 = (\vec{e_0}, \vec{e_1}, \vec{e_2})$, with column vectors $\vec{e_0} = (1,0,0)$, $\vec{e_1} = (0,1,0)$ and $\vec{e_2} = (0,0,1)$ as the source coordinate system ($O$ being its origin) and $B_1 = (\vec{u}, \vec{v}, \vec{w})$ as the target coordinate system ($\Omega$ being its origin) with $\vec{u}$, $\vec{v}$ and $\vec{w}$ that are known. In order to get the coordinates $x'$, $y'$ and $z'$ of point $P(x, y, z)$ within coordinate system $B_1$, follow these steps:

1. Translate the point with $-(\vec{O\Omega})$ (would correspond to considering that the target coordinate system has its origin in $O$).
2. Calculate the the rotation angles between each axis of the source system and its corresponding axis in the target system, knowing that $\angle(\vec{u},\vec{v}) = \arccos(\cos(\angle(\vec{u}, \vec{v}))$ and $\cos(\angle(\vec{u}, \vec{v})) = \frac{\vec{u} \cdot \vec{v}}{||\vec{u}|| \cdot ||\vec{v}||}$.
3. Apply successive $x$, $y$ and $z$ rotations to the translated point using previously obtained angles.

Let me know of any inaccuracies that may have been posted above.