7

I would like to indicate the directions of rotation and symbols used for the respective Euler angles. This would look nice using small circular arrows around the axes, as shown below:

Euler Axis Rotations

In this drawing, I added the arrows with Gimp afterwards. How can I do this using TikZ, and label the arrows?

MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}

% Redefine rotation sequence for tikz3d-plot to z-y-x
\newcommand{\tdseteulerxyz}{
\renewcommand{\tdplotcalctransformrotmain}{%
%perform some trig for the Euler transformation
\tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} 
\tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta}
\tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma}
%
\tdplotmult{\sasb}{\sinalpha}{\sinbeta}
\tdplotmult{\sasg}{\sinalpha}{\singamma}
\tdplotmult{\sasbsg}{\sasb}{\singamma}
%
\tdplotmult{\sacb}{\sinalpha}{\cosbeta}
\tdplotmult{\sacg}{\sinalpha}{\cosgamma}
\tdplotmult{\sasbcg}{\sasb}{\cosgamma}
%
\tdplotmult{\casb}{\cosalpha}{\sinbeta}
\tdplotmult{\cacb}{\cosalpha}{\cosbeta}
\tdplotmult{\cacg}{\cosalpha}{\cosgamma}
\tdplotmult{\casg}{\cosalpha}{\singamma}
%
\tdplotmult{\cbsg}{\cosbeta}{\singamma}
\tdplotmult{\cbcg}{\cosbeta}{\cosgamma}
%
\tdplotmult{\casbsg}{\casb}{\singamma}
\tdplotmult{\casbcg}{\casb}{\cosgamma}
%
%determine rotation matrix elements for Euler transformation
\pgfmathsetmacro{\raaeul}{\cacb}
\pgfmathsetmacro{\rabeul}{\casbsg - \sacg}
\pgfmathsetmacro{\raceul}{\sasg + \casbcg}
\pgfmathsetmacro{\rbaeul}{\sacb}
\pgfmathsetmacro{\rbbeul}{\sasbsg + \cacg}
\pgfmathsetmacro{\rbceul}{\sasbcg - \casg}
\pgfmathsetmacro{\rcaeul}{-\sinbeta}
\pgfmathsetmacro{\rcbeul}{\cbsg}
\pgfmathsetmacro{\rcceul}{\cbcg}
}
}

\tdseteulerxyz

\usepackage{siunitx}

\begin{document}
% Set the plot display orientation
% Syntax: \tdplotsetdisplay{\theta_d}{\phi_d}
\tdplotsetmaincoords{60}{110}

% Start tikz-picture, and use the tdplot_main_coords style to implement the display 
% coordinate transformation provided by 3dplot.
\begin{tikzpicture}[scale=3,tdplot_main_coords]

% Set origin of main (body) coordinate system
\coordinate (O) at (0,0,0);

% Draw main coordinate system
\draw[red, thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[red, thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[red, thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; 

\end{tikzpicture}

\end{document}
2
  • 1
    Are you looking for something like this: symbols for rotate around axis?
    – Alexander
    Commented Jun 7, 2013 at 10:07
  • Similar to this, but applicable in combination with the tikz-3dplot package.
    – Ingo
    Commented Jun 7, 2013 at 11:36

3 Answers 3

4

I used a arc with an arrow hat which I translated and rotated.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}

% Redefine rotation sequence for tikz3d-plot to z-y-x
\newcommand{\tdseteulerxyz}{
\renewcommand{\tdplotcalctransformrotmain}{%
%perform some trig for the Euler transformation
\tdplotsinandcos{\sinalpha}{\cosalpha}{\tdplotalpha} 
\tdplotsinandcos{\sinbeta}{\cosbeta}{\tdplotbeta}
\tdplotsinandcos{\singamma}{\cosgamma}{\tdplotgamma}
%
\tdplotmult{\sasb}{\sinalpha}{\sinbeta}
\tdplotmult{\sasg}{\sinalpha}{\singamma}
\tdplotmult{\sasbsg}{\sasb}{\singamma}
%
\tdplotmult{\sacb}{\sinalpha}{\cosbeta}
\tdplotmult{\sacg}{\sinalpha}{\cosgamma}
\tdplotmult{\sasbcg}{\sasb}{\cosgamma}
%
\tdplotmult{\casb}{\cosalpha}{\sinbeta}
\tdplotmult{\cacb}{\cosalpha}{\cosbeta}
\tdplotmult{\cacg}{\cosalpha}{\cosgamma}
\tdplotmult{\casg}{\cosalpha}{\singamma}
%
\tdplotmult{\cbsg}{\cosbeta}{\singamma}
\tdplotmult{\cbcg}{\cosbeta}{\cosgamma}
%
\tdplotmult{\casbsg}{\casb}{\singamma}
\tdplotmult{\casbcg}{\casb}{\cosgamma}
%
%determine rotation matrix elements for Euler transformation
\pgfmathsetmacro{\raaeul}{\cacb}
\pgfmathsetmacro{\rabeul}{\casbsg - \sacg}
\pgfmathsetmacro{\raceul}{\sasg + \casbcg}
\pgfmathsetmacro{\rbaeul}{\sacb}
\pgfmathsetmacro{\rbbeul}{\sasbsg + \cacg}
\pgfmathsetmacro{\rbceul}{\sasbcg - \casg}
\pgfmathsetmacro{\rcaeul}{-\sinbeta}
\pgfmathsetmacro{\rcbeul}{\cbsg}
\pgfmathsetmacro{\rcceul}{\cbcg}
}
}

\tdseteulerxyz

\usepackage{siunitx}

\begin{document}
% Set the plot display orientation
% Syntax: \tdplotsetdisplay{\theta_d}{\phi_d}
\tdplotsetmaincoords{60}{110}

% Start tikz-picture, and use the tdplot_main_coords style to implement the display 
% coordinate transformation provided by 3dplot.
\begin{tikzpicture}[scale=3,tdplot_main_coords]

% Set origin of main (body) coordinate system
\coordinate (O) at (0,0,0);

% Draw main coordinate system
\draw[red, thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[red, thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[red, thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; 


\newcommand{\circAr}%
{  \draw (0,0, 0) +(0:.05)[->] arc(0:360:.05);
}

\newcommand{\translatepoint}[1]%
{   \coordinate (mytranslation) at (#1);
}

   %circle around x
   \translatepoint{0.7,0,0}
   \tdplotsetmaincoords{30}{0}{0}
   \begin{scope}[tdplot_main_coords,shift=(mytranslation)]
       \circAr;
   \end{scope}
   \draw(0.7,0,0)node[anchor=north west]{$\theta_3$};

   %circle around y
   \translatepoint{0,0.7,0}
   \tdplotsetmaincoords{30}{0}{0}
   \begin{scope}[tdplot_main_coords,shift=(mytranslation)]
       \circAr;
   \end{scope}
   \draw(0,0.7,0)node[anchor=north west]{$\theta_2$};

   %circle around z
   \translatepoint{0,0,0.7}
   \tdplotsetmaincoords{50}{0}{0}
   \begin{scope}[tdplot_main_coords,shift=(mytranslation)]
       \circAr;
   \end{scope}
   \draw(0,0,0.7)node[anchor=north west]{$\theta_1$};

   \end{tikzpicture}

   \end{document}

The resulting image would look like this

enter image description here

1
  • 2
    It would look better if you can make them ellipses rather than circles
    – percusse
    Commented Jun 7, 2013 at 14:36
13

A pure tikz-3dplot solution is based on the macro tdplotsetthetaplanecoords and tdplotdrawarc.

At first, the tdplotdrawarc macro draws an arc in the x-y plane. The tdplotsetthetaplanecoords(\phi) will let you choose a plane based on the z-axis having a phi angle with the z-y plane.

Be careful, once in the theta plane, I don't know how to get back to the x-y plane.

You set up a macro \tdseteulerxyz to move on to Tait-Bryan angle, be carefull, my solution won't work in rotated coords. More on this in this question How to draw an Euler angle rotation sequence with TikZ?.

I don't really get how the coords work in the theta plane so I had to make some try but there is the code :

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}
% Set the plot display orientation
% Syntax: \tdplotsetdisplay{\theta_d}{\phi_d}
\tdplotsetmaincoords{60}{110}

% Start tikz-picture, and use the tdplot_main_coords style to implement the display 
% coordinate transformation provided by 3dplot.
\begin{tikzpicture}[scale=3,tdplot_main_coords]

% Set origin of main (body) coordinate system
\coordinate (O) at (0,0,0);

% Draw main coordinate system
\draw[red, thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
\draw[red, thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
\draw[red, thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$}; 

%Draw the arcs on each theta plane
%The first position is obvious since we are in the x-y plane and rotating around the z-axis.
%The anchor already went crazy, north is pointing downwards...
\tdplotdrawarc[->,color=black]{(0,0,0.7)}{0.1}{0}{350}{anchor=south west,color=black}{yaw}
%We move to the z-x axis
\tdplotsetthetaplanecoords{0}
%Notice you have to tell tiks-3dplot you are now in rotated coords
%Since tikz-3dplot swaps the planes in tdplotsetthetaplanecoords, the former y axis is now the z axis.
\tdplotdrawarc[tdplot_rotated_coords,->,color=black]{(0,0,0.7)}{0.1}{110}{460}{anchor=south west,color=black}{pitch}
\tdplotsetthetaplanecoords{-90}
%Once again we swaps the planes. I don't know why it's working like this but we turn backwards
%so the arrow turns in the positive direction.
\tdplotdrawarc[tdplot_rotated_coords,->,color=black]{(0,0,0.7)}{0.1}{120}{470}{anchor=south west,color=black}{roll}
% If you turn the theta plane  of 90 degrees position and rotation are inverted.
%\tdplotsetthetaplanecoords{90}
%\tdplotdrawarc[tdplot_rotated_coords,->,color=black]{(0,0,-0.7)}{0.1}{470}{120}{anchor=south east,color=black}{roll}
\end{tikzpicture}

\end{document}

There is yet a drawback, arrows don't go behind the axes but I don't know how to solve it...

enter image description here

0
5

You can use the 3d library for this:

Code

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{arrows,3d}

% fix the implementation of "canvas is xy plane at z"
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
  \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
  \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
  \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
  \tikz@canvas@is@plane
}
\makeatother

% define styles for the three coordinate planes
\tikzset{xyp/.style={canvas is xy plane at z=#1}}
\tikzset{xzp/.style={canvas is xz plane at y=#1}}
\tikzset{yzp/.style={canvas is yz plane at x=#1}}

\begin{document}

\begin{tikzpicture}[x={(-10:1cm)},y={(90:1cm)},z={(225:1cm)}]
\draw[-latex] (0,0,0) -- (5.5,0,0) node[pos=1.1] {$x$};
\draw[-latex] (0,0,0) -- (0,5.5,0) node[pos=1.1] {$y$};
\draw[-latex] (0,0,0) -- (0,0,5.5) node[pos=1.1] {$z$};

\draw[yzp=5,->,red] (0.2,0) arc (0:370:0.2) coordinate (xl);
\draw[xzp=5,->,red] (0.2,0) arc (0:370:0.2) coordinate (yl);
\draw[xyp=5,->,red] (0.2,0) arc (0:370:0.2) coordinate (zl);

\node[above right,blue] at (xl) {x label};
\node[right,blue] at (yl) {y label};
\node[right,blue] at (zl) {z label};
\end{tikzpicture}

\end{document}

Output

enter image description here

2
  • Thanks Tom, but how can I make this work with the tikz-3dplot package? Compatibility with this is important to me, because I draw all my frames with that package.
    – Ingo
    Commented Jun 7, 2013 at 11:35
  • +1 Is the fix just needed for old versions of 3d/tikz? - I see no difference on my 2022 system. Commented Jan 26, 2023 at 16:59

You must log in to answer this question.

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