23

For some lecture notes I want to illustrate successive unit axis rotations using Euler angles. I am quite happy with what I came up with so far:

Euler angle unit axis rotations

However, I am failing at drawing the angles in between the successive roations. For example, I would like to have theta_1 between x_I and x' etc. Like so: Example of desired output

where the lines should (ideally...) be arcs, and be labelled.

I achieve the last one of the pictures above with the following code using the tikz-3dplot package.

\begin{tikzpicture}[scale=2.5,tdplot_main_coords]

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

% Draw main coordinate system
\draw[red, ,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{I}}$}; 

% Intermediate frame 1
\tdplotsetrotatedcoords{\zRot}{0}{0}
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (1,0,0) node[anchor=north east]{$x'$};
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (0,1,0) node[anchor=west]{$y'$};
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (0,0,1) node[anchor=west]{$z'$};

% Intermediate frame 2
\tdplotsetrotatedcoords{\zRot}{\yRot}{0}
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (1,0,0) node[anchor=
north]{};
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (0,1,0)
node[anchor=west]{$y''$};
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (0,0,1)
node[anchor=south]{$z''$};

% Rotate to final frame
\tdplotsetrotatedcoords{\zRot}{\yRot}{\xRot}
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (1,0,0)
node[anchor=west]{$x_{\mathcal{B}}$, \textcolor{green}{$x''$}};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,1,0) node[anchor=west]{$y_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{B}}$};

\end{tikzpicture}

The full code is pasted here, not to crowd this up too much:
http://pastebin.com/pYW6iyEP

Long story short: How can I draw arcs in between the individual coordinate systems?

1

3 Answers 3

9

You can solve your problem using \tdplotdrawarc[coordinates_frame,->,colo]{origin}{radius}{start angle}{end angle}{node info}{label}
Before using that you might have to rotate the theta-plane using \tdplotsetrotatedthetaplanecoords{angle}. I find it kind of unintuitive to use/ difficult to imagine how the angles should be. Therefore, it might really help to first draw a complete circle using \tdplotdrawarc[coordinates_frame,->,colo]{origin}{radius}{0}{360}{node info}{label} and adapting the angle in \tdplotsetrotatedthetaplanecoords{angel} until the circle is in the correct plane.

A solution to your third picture would be:

\begin{tikzpicture}[scale=2.5,tdplot_main_coords]

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

% Draw main coordinate system
\draw[red, ,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{I}}$};



% Intermediate frame 1
\tdplotsetrotatedcoords{\zRot}{0}{0}
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (1,0,0) node[anchor=north east]{$x'$};
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (0,1,0) node[anchor=west]{$y'$};
\draw[tdplot_rotated_coords,->, blue] (0,0,0) -- (0,0,1) node[anchor=west]{$z'$};

\tdplotsetrotatedthetaplanecoords{90}
%draw theta arc and label
%\tdplotdrawarc[tdplot_rotated_coords,->,color=blue]{(0,0,0)}{0.5}{0}{350}{anchor=south west,color=gray}{$\alpha$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{80}{90}{anchor=south west,color=gray}{$\alpha$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{170}{180}{anchor=south west,color=gray,  yshift = -15 pt}{$\alpha$}

%% Intermediate frame 2
\tdplotsetrotatedcoords{\zRot}{\yRot}{0}
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (1,0,0) node[anchor=
north]{};
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (0,1,0)
node[anchor=west]{$y''$};
\draw[,tdplot_rotated_coords,->, green] (0,0,0) -- (0,0,1)
node[anchor=south]{$z''$};
\tdplotsetrotatedthetaplanecoords{60}
%draw theta arc and label
%\tdplotdrawarc[tdplot_rotated_coords,->,color=green]{(0,0,0)}{0.5}{0}{350}{anchor=north,color=gray}{$\beta$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{80}{90}{anchor=north,color=gray}{$\beta$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{310}{320}{anchor=south west,color=gray}{$\beta$}
% 
% Rotate to final frame
\tdplotsetrotatedcoords{\zRot}{\yRot}{\xRot}
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (1,0,0)
node[anchor=west]{$x_{\mathcal{B}}$, \textcolor{green}{$x''$}};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,1,0) node[anchor=west]{$y_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{B}}$};

\tdplotsetrotatedthetaplanecoords{30}
%draw theta arc and label
%\tdplotdrawarc[tdplot_rotated_coords,->,color=cyan]{(0,0,0)}{0.5}{0}{350}{anchor=north,color=gray}{$\gamma$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{215}{225}{anchor=north,color=gray, yshift = 15pt}{$\gamma$}
\tdplotdrawarc[tdplot_rotated_coords,->,color=gray]{(0,0,0)}{0.5}{328}{338}{anchor=south west,color=gray}{$\gamma$}

\end{tikzpicture}

solution to the third frame

0
9

I got stucked with the same problem and Zwähnia's solution is great and works perfectly in the case you works with Euler angle but couldn't help me with Tait-Bryan angle. There is kind of a bug and I couldn't track it down yet, so there is a workaround.

The problem I had comes from the fact you redefined the \tdplotcalctransformrotmain command (and so did I). This makes in some point tikz-3dplot go crazy. As you can see in the first graph, using tikz-3dplot implementation of the rotation, the circle are drawn in the z_B - x_B plane (the blue circle), y_B - z_B (the red circle) and x_B - y_B (the black circle) whereas in the Tait-Bryan case the red and the black circle are in the same plane Comparison of Euler and Tait-Bryan

The codes are similar though...

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
% Workaround for making use of externalization possible
% -> remove hardcoded pdflatex and replace by lualatex
\usepgfplotslibrary{external}

% 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}
  }
}

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

\pgfmathsetmacro{\zRot}{10}
\pgfmathsetmacro{\yRot}{10}
\pgfmathsetmacro{\xRot}{10}
%%%%%%%%% Using standard euler angles implemented in default tikz-3dplot implementation
\begin{document}
%%%%%%%%%%%%% Z-Y-Z
\begin{tikzpicture}[scale=2.5,tdplot_main_coords]

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

% Draw main coordinate system
\draw[red, ,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{I}}$};

% Rotate to final frame
\tdplotsetrotatedcoords{\zRot}{\yRot}{\xRot}
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (1,0,0) node[anchor=west]{$x_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,1,0) node[anchor=west]{$y_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{B}}$};

%Draws circle representing the rotated planes. Each of these should be "pointed" by two arrows.
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=black]{(0,0,0)}{1}{0}{350}{anchor=south west,color=black}{$x-y$}
\tdplotsetrotatedthetaplanecoords{0}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=blue]{(0,0,0)}{1}{0}{350}{anchor=south west,color=blue}{$x-z$}
\tdplotsetrotatedthetaplanecoords{90}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=red]{(0,0,0)}{1}{0}{350}{anchor=south west,color=red}{$y-z$}
\end{tikzpicture}

%%%%%% Change the rotation matrix in order to use Tait-Bryan angles
\tdseteulerxyz
%%%%%%%%%%%%% Z-Y-X
\begin{tikzpicture}[scale=2.5,tdplot_main_coords]

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

% Draw main coordinate system
\draw[red, ,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{I}}$};

% Rotate to final frame
\tdplotsetrotatedcoords{\zRot}{\yRot}{\xRot}
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (1,0,0) node[anchor=west]{$x_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,1,0) node[anchor=west]{$y_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{B}}$};

%Draws circle representing the rotated planes. Each of these should be "pointed" by two arrows.
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=black]{(0,0,0)}{1}{0}{350}{anchor=south west,color=black}{$x-y$}
\tdplotsetrotatedthetaplanecoords{0}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=blue]{(0,0,0)}{1}{0}{350}{anchor=south west,color=blue}{$x-z$}
\tdplotsetrotatedthetaplanecoords{90}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=red]{(0,0,0)}{1}{0}{350}{anchor=south west,color=red}{$y-z$}
\end{tikzpicture}
\end{document}

I wanted to preserve the use of the angle macros \xRot, \yRot and \zRot which is not possible anymore if you set up the tdplotsetrotatedthetaplanecoords as does Zwähnia. A working Tait-Bryan representation

My solution consists in turning the coords backwards to find easily the good theta plane.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{pgfplots}
% Workaround for making use of externalization possible
% -> remove hardcoded pdflatex and replace by lualatex
\usepgfplotslibrary{external}

% 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}
  }
}

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

\pgfmathsetmacro{\zRot}{10}
\pgfmathsetmacro{\yRot}{10}
\pgfmathsetmacro{\xRot}{10}
%%%%%%%%% Using standard euler angles implemented in default tikz-3dplot implementation
\begin{document}
%%%%%% Change the rotation matrix in order to use Tait-Bryan angles
\tdseteulerxyz
%%%%%%%%%%%%% Z-Y-X
\begin{tikzpicture}[scale=2.5,tdplot_main_coords]

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

% Draw main coordinate system
\draw[red, ,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y_{\mathcal{I}}$};
\draw[red, ,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{I}}$};

% Rotate to final frame
\tdplotsetrotatedcoords{\zRot}{\yRot}{\xRot}
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (1,0,0) node[anchor=west]{$x_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,1,0) node[anchor=west]{$y_{\mathcal{B}}$};
\draw[thick,tdplot_rotated_coords,->, cyan] (0,0,0) -- (0,0,1) node[anchor=south]{$z_{\mathcal{B}}$};

%Draws circle representing the rotated planes. Each of these should be "pointed" by two arrows.
%\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=black]{(0,0,0)}{1}{0}{350}{anchor=south west,color=black}{$x-y$}
\tdplotsetrotatedthetaplanecoords{0}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=blue]{(0,0,0)}{1}{0}{350}{anchor=south west,color=blue}{$x-z$}
\tdplotsetrotatedthetaplanecoords{90}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=black]{(0,0,0)}{1}{0}{350}{anchor=south west,color=black}{$y-z$}

% Instead, rotates in the opposite direction
\tdplotsetrotatedcoords{\zRot+90}{\yRot}{\xRot}
%Draw the last circle in the right plane
\tdplotsetrotatedthetaplanecoords{0}
\tdplotdrawarc[dashed,tdplot_rotated_coords,->,color=red]{(0,0,0)}{1}{0}{350}{anchor=south west,color=red}{$x-z$}

\end{tikzpicture}
\end{document}

It's not really pretty but it has the advantage of staying with the use of the angle macros and allows to draw the sequence as I wanted it (I finish my last tikzpicture and I update my answer with it).

Hope this helps.

Cheers.

7
  • Could you explain how you constructed those circles or ellipses in 3D instead of a 2D plane? I have been looking for an answer to that here
    – dustin
    Commented Jul 16, 2013 at 13:59
  • I used the dedicated package tikz-3dplot. Nevertheless I don't know how to draw 3D ellipses using this package, only 3d circles which appears as ellipses.
    – Vser
    Commented Jul 16, 2013 at 14:33
  • Unfortunately my "solution" in the previous post isn't really working ; I didn't tested it carefully enough. As soon as I get a solution I'll update the answer.
    – Vser
    Commented Jul 16, 2013 at 16:09
  • If you need the transposed matix, you can modify the example: % Redefine rotation sequence for tikz3d-plot to x-y-z \newcommand{\tdseteulerzyx}{ ... %determine rotation matrix elements for Euler transformation \pgfmathsetmacro{\raaeul}{\cacb} \pgfmathsetmacro{\rabeul}{\sacb} \pgfmathsetmacro{\raceul}{-\sinbeta} \pgfmathsetmacro{\rbaeul}{\casbsg - \sacg} \pgfmathsetmacro{\rbbeul}{\sasbsg + \cacg} \pgfmathsetmacro{\rbceul}{\cbsg} \pgfmathsetmacro{\rcaeul}{\sasg + \casbcg} \pgfmathsetmacro{\rcbeul}{\sasbcg - \casg} \pgfmathsetmacro{\rcceul}{\cbcg} } }
    – Konne
    Commented Jan 4, 2015 at 14:27
  • @Konne Sorry, this post is like a year old and I can't remember what I was doing then :) I even totally forgot I swore to edit my post when solved... Thanks to reminding me this answer, maybe I'll try to update it ! But anyway, I don't think it was about transposing ;)
    – Vser
    Commented Jan 5, 2015 at 15:24
3

Here is a different proposal based on two other parametrizations -- Euler z-x-z and Cardan x-y-z. The full code can be found here on Pastebin.

The general idea is as follows:

% Define new arc command
% Syntax: [draw options] (center) (initial angle:final angle:radius)
% https://tex.stackexchange.com/a/66220
\def\centerarc[#1](#2)(#3:#4:#5){%
    \draw [#1] ($(#2)+({#5*cos(#3)}, {#5*sin(#3)})$) arc (#3:#4:#5)%
}

\centerarc[tdplot_rotated_coords, canvas is yx plane at z=0.7, arrows = {latex}-{}](0, 0)(230 : 570 : 0.15)%
        node[anchor = north west, xshift = +2mm, yshift = -3mm, inner sep = \TikzInnerSep]%
            {1. $\psi$};

Results:

Euler Angles (Coordinate Transformation) Visualization with TikZ Cardan Angles (Coordinate Transformation) Visualization with TikZ

1
  • 1
    Welcome to TeX.SX! Please post your minmale working answer directly. The link doesn't work in some time.
    – Bobyandbob
    Commented Sep 23, 2017 at 11:32

You must log in to answer this question.

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