How can I create a simple 3D diagram containing two reference frames using the TikZ package? For reference purpose, the diagram may look approximately like this one:enter image description here

  • Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – samcarter is at topanswers.xyz Dec 26 '16 at 14:27
  • @samcarter I edited the comment as you suggested. Are the changes OK? – Lionel Dec 26 '16 at 14:38
  • Have you tried anything yourself? If so, please add the code you have. (\draw [-latex] (0,0,0) -- (4,0,0) node [right] {$i_1$}; and similar will get you a long way I think.) – Torbjørn T. Dec 26 '16 at 14:48

TikZ lets you specify coordinates in three dimensions, which it projects onto the page. Importantly, you can specify (and locally change) that projection. If you want to use several coordinate systems in the same image, you might want to set styles for them.

\documentclass[tikz, border=5pt]{standalone}
  > = {stealth},
  % specifying distances in cm puts them in the paper coordinates,
  % without units puts them in these tikz xy(z) coordinates
  inertial frame/.style = {x={(-20:2cm)}, y={(-160:2cm)}, z={(90:2cm)}},
  local frame/.style = {shift={(local origin)}, x={(40:.7cm)}, y={(150:.7cm)}, z={(105:.7cm)}}

\begin{tikzpicture}[scale=2, inertial frame]
  % draw axes
  \draw[->] (0,0,0) -- (1,0,0) node[above] {$i_1$};
  \draw[->] (0,0,0) -- (0,1,0) node[above] {$i_2$};
  \draw[->] (0,0,0) -- (0,0,1) node[left] {$i_3$};
  % draw dashed lines and set the coordinate (local origin) which is used in the local frame style
  \draw[dashed] (0,0,0) -- ++(15:1) coordinate (projection) -- ++(0,0,1) coordinate (local origin);

  \draw[very thick, ->] (0,0,0) -- (local origin);
  \draw[<->] (90:.5) arc (90:15:.5) node[below, pos=.5] {$\alpha$};
  % arcs are drawn in the x-y plane, so locally set x and y to an orthonormal basis to the desired plane
  \draw[y={(0,0,1)}, x={(projection)}, <->] (0:.4) arc (0:45:.4) node[right, pos=.5] {$\delta$};

  \begin{scope}[local frame]
    % draw local axes
    \draw[->] (0,0,0) -- (1,0,0) node[above] {$l_1$};
    \draw[->] (0,0,0) -- (0,1,0) node[above] {$l_2$};
    \draw[->] (0,0,0) -- (0,0,1) node[left] {$l_3$};
    % draw right angle
    \draw[thin] (.2,0,0) -- (.2,.2,0) -- (0,.2,0);

enter image description here

Since the above style for local frame refers to the coordinate (local origin), you need to define that coordinate before using the style.


I hope to have help you with a simple code (2D).

enter image description here

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-3.52,-2.76) rectangle (7.36,5.76);
\draw (0,0) -- (-23.1:1.4) arc (-23.1:43.3:1.4) -- cycle;
\draw [->] (0.,0.) -- (0.,4.);
\draw [->] (0.,0.) -- (-2.84,-2.02);
\draw [->,line width=1.6pt] (0.,0.) -- (3.84,3.62);
\draw [dash pattern=on 4pt off 4pt] (3.84,3.62)-- (3.84,-1.64);
\draw [dash pattern=on 4pt off 4pt] (0.,0.)-- (3.84,-1.64);
\draw [shift={(-0.4,1.76)}] plot[domain=4.4:5.3,variable=\t]({1.*2.79*cos(\t r)+0.*2.79*sin(\t r)},{0.*2.79*cos(\t r)+1.*2.79*sin(\t r)});
\draw [->] (0.,0.) -- (5.34,-1.3);
\draw [->] (3.84,3.62) -- (2.2,4.42);
\draw [->] (3.84,3.62) -- (3.44,5.5);
\draw [->] (3.84,3.62) -- (5.28,4.78);
\draw (3.4,3.85)-- (3.8,4.22);
\draw (3.8,4.22)-- (4.28,4);
\draw (-0.54,4.74) node[anchor=north west] {$\mathbf{i_3}$};
\draw (-3.2,-1.4) node[anchor=north west] {$\mathbf{i_2}$};
\draw (0.08,-0.9) node[anchor=north west] {$\mathbf{\alpha}$};
\draw (1.4,0.8) node[anchor=north west] {$\mathbf{\delta}$};
\draw (5.48,-0.96) node[anchor=north west] {$\mathbf{i_1}$};
\draw (3.66,5.82) node[anchor=north west] {$\mathbf{i_3}$};
\draw (5.36,5.5) node[anchor=north west] {$\mathbf{i_1}$};
\draw (1.9,5.28) node[anchor=north west] {$\mathbf{i_2}$};
\draw [fill=white] (0.,0.) circle (0.5pt);

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.