I am using tikz-3dplot and trying to represent navigation system transformations. In navigation systems, the orientation of the vehicle axis is given in terms of Roll, Pitch and Yaw. These are generally represented as Euler angles of Phi, Theta, and Psi.

I am trying to represent the following:

Rotate about the Z axis by Psi, the Yaw angle. Then, Rotate about the new Y axis by the pitch angle (Theta). Then, Rotate about the new X axis the roll angle (Phi).

The challenge I am having is that Tikz-3dplot rotates about the Z, Y then Z axis. According to the documentation, these rotations should be relative to the "world" Z, Y, and Z axes. After reading up on Euler angles (on Wikipedia), I was educated to the fact that there are actually multiple representations of the Euler angles, and the Z,Y,Z is one, as is the Z,Y,X that I was familiar with.

The problem I have now is that it appears that when I apply the tikz-3dplot command: \tdplotsetrotatedcoords{\psi}{\theta}{\phi} that the first rotation is about the Z axis, as expected. The second rotation (\theta), is about the ROTATED Y axis, which is really what I want, but NOT what the documentation claims. Unfortunately, here is where I am stuck. The final rotation, which needs to be about the rotated X axis, in fact rotates about the ROTATED Z axis...

If the rotations were about the world axes, I could come up with a transform (although I would really have to think about it).. but, since they are not, I am completely stumped as to how to get that final rotated system...

I have been doing a lot of searching for answers.. and come up with very little. I've even tried to modify the tikz-3dplot package, making a copy of my own.. this might work, but I am hoping there is a better answer, as I really don't have time to learn enough about tex to do this.. nor the time to troubleshoot it.

Keywords to make more discoverable in search engines:

z-y-z sequence, z-y-x sequence, rotation sequence

  • 1
    If Jakes answer solved your problem, please accept it by clicking the checkmark to the left, thereby marking the question as "solved" and awarding some points to both Jake and yourself. Commented Dec 2, 2011 at 10:18
  • Ed, can you please mark this as solved? Thanks.
    – Ingo
    Commented Apr 18, 2013 at 11:05

1 Answer 1


Here's a macro \tdseteulerxyz that sets the Euler matrix to use an XYZ (yaw-pitch-roll) order for the rotations. The matrix is taken from Wikipedia, where you can also find the matrices for the other rotation orders. Note that this is the reverse of how tikz-3dplot normally uses its arguments to \tdplotsetrotatedcoords; the first argument is roll and the last is yaw.

Here are two tikz-3dplot pictures that are identical except for the fact that \tdseteulerxyz was called just before the second picture.

And here's the code:



%perform some trig for the Euler transformation
%determine rotation matrix elements for Euler transformation
\pgfmathsetmacro{\rabeul}{\casbsg - \sacg}
\pgfmathsetmacro{\raceul}{\sasg + \casbcg}
\pgfmathsetmacro{\rbbeul}{\sasbsg + \cacg}
\pgfmathsetmacro{\rbceul}{\sasbcg - \casg}

\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) --
(.7,0,0) node[anchor=north]{$x'$};
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) --
(0,.7,0) node[anchor=west]{$y'$};
\draw[thick,color=blue,tdplot_rotated_coords,->] (0,0,0) --
(0,0,.7) node[anchor=south]{$z'$};


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .