# How do I convert vectors between rotated cartesian coordinate systems? [closed]

I am trying to understand how to transform vectors between cartesian coordinate systems that are rotated wrt each others. As a step in this process I have come up with a toy problem:

Consider a ground station, G. Let us introduce a right handed coordinate system with origin in G, x-axis pointing north and y-axis pointing east.

A plane, B, is located at: $$\vec{GB}_G=[2000,4000,-1000]$$

Its orientation is: yaw = 90 degrees, pitch = roll = 0.

It reports seing another plane, O, at position: $$\vec{BO}_B=[3000,-3000,0]$$ but this is relative to its own origin, B, and using it owns basis vectors $$\{\hat{x_B},\hat{y_B},\hat{z_B}\}$$.

What is the position of the other plane in the G coordinate system, $$\vec{GO}_G$$? That is using G as origin and using the G basis vectors $$\{\hat{x_G},\hat{y_G},\hat{z_G}\}$$.

The curvature of the earth can be ignored since the distances are small.

Also in the more general case pitch and roll are different from 0. How is the problem then solved?

The yaw, pitch and roll describes how to rotate the basis of the G coordinate system: $$\{\hat{x_G},\hat{y_G},\hat{z_G}\}$$ to get the basis of the B coordinate system: $$\{\hat{x_B},\hat{y_B},\hat{z_B}\}$$:

• the G basisvectors are first rotated yaw around the the z-axis
• the new basisvectors are rotated pitch around the new y-axis
• the new basisvectors are rotated roll around the new x-axis and the result is the B basis vectors
• Your 1st coordinate system is common, and it's called North East Down (NED).
– JEB
Commented Mar 19, 2023 at 16:15
• I think I don't understand the question. What does pitch, yaw, and roll have to do with anything? Also, the issue here seems to be more about relative frames than rotated frames. Can you clarify? Commented Mar 19, 2023 at 16:47

For this specific problem involving aircraft relative to Earth, you have chosen a decent frame: North East Down (NED), which is a local tangent plane: https://en.wikipedia.org/wiki/Local_tangent_plane_coordinates

Note the East, North, Up (ENU) is more common for ground positions, while NED is common for air/space borne sensors looking down.

From there, there are two common ways to express plane orientation, you chose my favorite: Yaw, Pitch, and Roll:

As such, these are called intrinsic Tait-Bryan angles: https://en.wikipedia.org/wiki/Euler_angles#Tait–Bryan_angles

The transformations (rotation matrices) are listed in the linked articles.

Roll, pitch and yaw are nice because the final rotation is just a composition of each rotation:

$$R_{ij} = R^{\rm roll}_{jk}R^{\rm pitch}_{kl}R^{\rm yaw}_{lm}$$

where operators act from the left:

$$v'_i = R_{ij}v_j$$

Be aware of active and passive rotations (also called alibi and alias). The former(s) rotate the vector, while a latter(s) rotate the coordinate system.

Tait-Bryan angles are preferable over Euler angles because they don't have any degeneracy. I always wondered why Euler would pick angles with a degeneracy, until I started using them: you can compute the inverse rotation without any computation, a limitation we no longer suffer.

Your problem also involves translations, so you want to consider a sub-class of affine transformation, a rotation plus a translation:

$${\bf A}(\vec v)_i = R_{ij}v_j + T_i$$

These also come in active/passive flavors, and sometimes have the translation 1st..I avoid that formulation.

Also: I suggest you use better names for your vectors. "GBB" is too confusing. Things like $$P$$ and $$P'$$ are preferable. And your drawing is completely confusing...north is up, up should be up, east should to the right...idk. I might get the wrong answer because of it:

The answer in NED at $$G$$ is:

$$\vec P = (5000, 7000, -1000)$$

The height error from Earth's curvature is around 5.8m, depending on $$G$$'s latitude.

Finally: in practice, quaternions are preferable to rotation matrices for implementation in flight, but that's a different question.

• Could you please show me the steps you used to arrive at your answer vector?
– Andy
Commented Mar 19, 2023 at 17:25
• No, I can't. I used SW I wrote, and its ITAR controlled. I recommend: drawing a clearer diagram, with simple names for points (not vectors, points) $G, P_1, P_2$ and sit in you office chair and stick out you arms along N, E, and be $P_1$, then yaw the chair 90 to the right an figure out the coordinates of $P_2$, and rotate back to $G$, add that vector to $\vec P_1$. That's how I sanity checked my dusty SW.
– JEB
Commented Mar 19, 2023 at 17:38
• Passive rotation of axes from G to B: $P=\begin{bmatrix} cos(\theta) & sin(\theta) \\ -sin(\theta) & cos(\theta) \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}$ Active rotation of vector from B to G: $A=P^{-1}=\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$ Thus: $\vec{BO_G}=\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}*[3000,-3000]=[3000,3000]$ Finally $\vec{GO_G}=\vec{GB_G}+\vec{BO_G}=[2000,4000,-1000]+[3000,3000] = [5000,7000,-1000]$.
– Andy
Commented Mar 19, 2023 at 22:19

This problem can be solved in a general way via a basis change, where one basis is related to the other via a 90° rotation. More about this can be found on the following wiki page: https://en.wikipedia.org/wiki/Rotation_matrix .

When you converted the basis, the two frames are compatible in the sense that you can just add and substract component wise.