Is it possible to find the unit vector with:
Roll € [-90 (banked to right), 90 (banked to left)],
Pitch € [-90 (all the way down), 90 (all the way up)]
Yaw € [0, 360 (N)]
I calculated it without the Roll and it is
\begin{pmatrix} cos(Pitch) sin(Yaw)\\ cos(Yaw) cos(Pitch)\\ sin(Pitch) \end{pmatrix}.
How should it be with the Roll rotation and how can I get to this result?
My coordinate system is with +z up, +x right and +y forward
Many thanks!

  • $\begingroup$ A unit vector gives you a pointing direction only. Suppose the unit vector points in the direction of travel of a jet fighter. You can roll the fighter upside down without changing the vector of its direction of travel. Roll has no effect on that vector. So perhaps you already have found the vector you need. If that's not right, you need to give more details to explain exactly what you think roll, pitch, and yaw should do to a vector, and why. $\endgroup$ – David K Feb 2 '16 at 15:02
  • $\begingroup$ Hello David, thanks for the interest. In addition to the Direction vector there is a "Up" vector which defines where the top of the jet points. This vector is the same as the above, but with Pitch -> 90+Pitch which becomes -sin(Pitch), -sin(Pitch) and cos(Pitch) using trigonometric identities. The direction of this "Up" vector takes into consideration the Roll of the jet, that's why I was asking for it. I do, however, agree I didn't explain it too well in the main post. Thanks again :) $\endgroup$ – LaTravavax Feb 2 '16 at 16:08
  • $\begingroup$ Double reply since there were too many characters: You can understand this better if you put your left hand in a "finger gun" position: the thumb is the "Up" vector while the index finger is the direction vector. If you rotate your hand around the Roll axis, as you said and as I understood, the direction vector is unchanged but the "Up" vector will be affected by the Roll. The "unaffected by Roll" "Up" vector is V = [-sin(Pitch), -sin(Pitch) and cos(Pitch)]. $\endgroup$ – LaTravavax Feb 2 '16 at 16:14

There are a lot of questions like this, all slightly different. My earlier answer to a different question is closely related to what you need, but the question is different enough that I thought it better to write an answer a little more applicable to your case.

I'll use right-handed $x,y,z$ Cartesian coordinates. I visualize roll, pitch, and yaw using the motion of someone's right hand, whose thumb and index finger are kept outstretched at right angles.

We start out with index finger of pointing in the direction $(0,1,0)^T$ (positive $y$ axis) and thumb pointing in the direction $(0,0,1)^T$ (positive $z$ axis). We turn the entire hand by the angle $\theta$ (the "yaw" angle) counterclockwise around the $z$ axis. We then rotate the hand in the plane now occupied by the index finger and thumb, turning it by the angle $\phi$ (the "pitch" angle) with the index finger moving in the direction of the thumb.

At this point the angles $\phi$ and $\theta$ describe the direction of the index finger in something like geographic coordinates, where $\phi$ corresponds to latitude and $\theta$ corresponds to longitude. (Note that these are not the kind of "mathematical" spherical coordinates where $\phi$ is the angle of a vector relative to the $z$-axis.)

Finally, we rotate the hand using the direction of the index finger as the axis of rotation, turning the thumb toward the palm of the hand by an angle $\psi$ (the "roll" angle).

The effect of these motions on a vector "attached" to the hand can be represented by a $3\times3$ matrix. We can decompose this matrix into a product of three much simpler matrices. Each of these three matrices will be a rotation around one of the principal axes ($x$, $y$, or $z$ axes), unlike the pitch and roll motions described above, which were performed around axes relative to an already-rotated hand.

To reproduce the result of the roll, pitch, and yaw on the orientation of the hand, using rotations only around the principal axes, we have to do the rotations in reverse order. This is so that we can still do pitch and roll around the correct axes relative to the hand, but do them while those axes are still aligned with the principal axes.

We do the "roll" through angle $\psi$ first, using the rotation matrix $$ R_y(\psi) = \begin{pmatrix} \cos\psi & 0 & -\sin\psi \\ 0 & 1 & 0 \\ \sin\psi & 0 & \cos\psi \end{pmatrix} $$ (a rotation around the $y$-axis), then the "pitch" through angle $\phi$, using the matrix $$ R_x(\phi) = \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos\phi & -\sin\phi \\ 0 & \sin\phi & \cos\phi \end{pmatrix} $$ (a rotation around the $x$-axis), and finally the "yaw" through angle $\theta$, using the matrix $$ R_z(\theta) = \begin{pmatrix} \cos\theta & \sin\theta & 0\\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix} $$ (a rotation around the $z$-axis). These are much like the axis-rotation matrices used in several other places (including my earlier answer), but with a sequence of axes and signs of the matrix entries suitable to your system.

The best way to understand how this works may be to try several examples, using simple pitch, roll, and yaw angles such as $\pi/2$ or $\pi/4$, and confirm that this sequence of rotations around fixed principal coordinate axes has the same result as the desired sequence of rotations around axes defined by the orientation of the hand.

This sequence of rotations is equivalent to the single rotation performed by the matrix product $R_z(\theta)R_y(\phi)R_x(\psi)$. For example, here's what this rotation does to the direction of the index finger, $(0,1,0)^T$: \begin{align} R_z(\theta) R_x(\phi) R_y(\psi) \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix} &= R_z(\theta) R_x(\phi) \begin{pmatrix} \cos\psi & 0 & -\sin\psi \\ 0 & 1 & 0 \\ \sin\psi & 0 & \cos\psi \end{pmatrix} \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix} \\ &= R_z(\theta) R_x(\phi) \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix} \\ &= R_z(\theta) \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos\phi & -\sin\phi \\ 0 & \sin\phi & \cos\phi \end{pmatrix} \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix} \\ &= R_z(\theta) \begin{pmatrix} 0 \\ \cos\phi \\ \sin\phi \end{pmatrix} \\ &= \begin{pmatrix} \cos\theta & \sin\theta & 0\\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 0 \\ \cos\phi \\ \sin\phi \end{pmatrix} \\ &= \begin{pmatrix} \cos\phi \sin\theta \\ \cos\phi \cos\theta \\ \sin\phi \end{pmatrix}, \\ \end{align} which agrees with your result.

What this same rotation does to the direction of the thumb, $(0,0,1)^T$, is \begin{align} R_z(\theta) R_x(\phi) R_y(\psi) \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix} &= R_z(\theta) R_x(\phi) \begin{pmatrix} \cos\psi & 0 & -\sin\psi \\ 0 & 1 & 0 \\ \sin\psi & 0 & \cos\psi \end{pmatrix} \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix} \\ &= R_z(\theta) R_x(\phi) \begin{pmatrix} -\sin\psi \\ 0 \\ \cos\psi \end{pmatrix} \\ &= R_z(\theta) \begin{pmatrix} 1 & 0 & 0 \\ 0 & \cos\phi & -\sin\phi \\ 0 & \sin\phi & \cos\phi \end{pmatrix} \begin{pmatrix} -\sin\psi \\ 0 \\ \cos\psi \end{pmatrix} \\ &= R_z(\theta) \begin{pmatrix} -\sin\psi \\ -\cos\psi \sin\phi \\ \cos\psi \cos\phi \end{pmatrix} \\ &= \begin{pmatrix} \cos\theta & \sin\theta & 0\\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} -\sin\psi \\ -\cos\psi \sin\phi \\ \cos\psi \cos\phi \end{pmatrix} \\ &= \begin{pmatrix} -\sin\psi \cos\theta - \cos\psi \sin\phi \sin\theta \\ \sin\psi \sin\theta - \cos\psi \sin\phi \cos\theta \\ \cos\psi \cos\phi \end{pmatrix} \\ \end{align} if I haven't dropped a sign or made some other arithmetic error.

  • $\begingroup$ That's some amazing math and it works flawlessly! Here's a GeoGebra applet I made to showcase this beautiful rotation matrix: link .I still have to understand how matrices work since I got my starting vector just from trigonometry and a couple of tests :) What a pity you can only upvote once! $\endgroup$ – LaTravavax Feb 2 '16 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.