12
    \documentclass[tikz]{standalone}
    \usepackage{tikz-3dplot}
    \begin{document}
    \begin{tikzpicture}[scale=2]
        % draw arcs
        \draw[canvas is zx plane at y = 1, line width = 1pt] (2,1) arc (-90:-180:1);
        \draw[canvas is zx plane at y = 1, opacity = 0.2, line width = 1pt] (2,1) arc (90:180:1);
        \draw[canvas is zy plane at x = 1, opacity = 0.2, line width = 1pt] (2,1) arc (-90:-180:1);
        \draw[canvas is zy plane at x = 1, opacity = 0.2, line width = 1pt] (2,1) arc (90:180:1);   

        %draw the axes
        \draw[red,->] (1,1,2) -- (1, 1, -1.1) node[anchor=north west]{$x$};
        \draw[blue,->] (1,1,2) -- (3.5,1,2) node[anchor=west]{$z$};
        \draw[blue,->] (1,1,2) -- (1,-1.2,2) node[anchor=north]{$y$};
    \end{tikzpicture}
    \end{document}

Rotated arc

Hello,

I have the following problem. I want the black arc in xz-plane to be rotated around the drawn x-axis. I only arrived at 90°-rotation-steps, but I want the rotation-steps to be for example 5°. Can anyone help me with that problem?

Thanks, Nico

2 Answers 2

10

I have simplified the code by placing the origin at (0,0,0).

The point of view can be set using:

\tdplotsetmaincoords{70}{110} % rotation about the x and y axis

The black arc rotation can be set using:

\tdplotsetrotatedcoords{0}{0}{-5} % rotation about the x, y and z axis

enter image description here

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}

\tdplotsetmaincoords{70}{110}     % point of view
\tdplotsetrotatedcoords{0}{0}{-5} % black arc rotation (x,y,z)

\begin{tikzpicture}[tdplot_main_coords,scale=1]
  %draw the axes
  \draw[blue,->] (0,0,0) -- (2,0,0) node[anchor=south]{$x$};
  \draw[blue,->] (0,0,0) -- (0,2,0) node[anchor=north]{$y$};
  \draw[red,->]  (0,0,0) -- (0,0,2) node[anchor=west]{$z$};

  % draw arcs  
  \draw[canvas is yz plane at x = 0, opacity = 0.2, line width = 1pt]
    (0,0) arc (0:90:1);
  \draw[canvas is yz plane at x = 0, opacity = 0.2, line width = 1pt]
    (0,0) arc (0:-90:-1);
  \draw[canvas is xz plane at y = 0, opacity = 0.2, line width = 1pt]
    (0,0) arc (0:-90:-1);

  \draw[tdplot_rotated_coords, canvas is zx plane at y = 0, line width = 1pt]
    (0,0) arc (90:0:1);

\end{tikzpicture}
\end{document}

Animated version (just for fun):

enter image description here

The code:

\documentclass{beamer}
\usepackage{tikz,tikz-3dplot}
\setbeamertemplate{navigation symbols}{}

\tikzset{
  invisible/.style={opacity=0},
  visible on/.style={alt={#1{}{invisible}}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
  },
}

\begin{document}

\tdplotsetmaincoords{70}{110}    % point of view
\tdplotsetrotatedcoords{0}{0}{0} % black arc rotation (x,y,z)

\begin{frame}
\centering
\begin{tikzpicture}[tdplot_main_coords]
    %draw the axes  
    \draw[blue,->] (0,0,0) -- (2,0,0) node[anchor=south]{$x$};
    \draw[blue,->] (0,0,0) -- (0,2,0) node[anchor=north]{$y$};
    \draw[red,->]  (0,0,0) -- (0,0,2) node[anchor=west]{$z$};

    % draw arcs  
    \draw[canvas is yz plane at x = 0, opacity = 0.2, line width = 1pt]
      (0,0) arc (0:90:1);
    \draw[canvas is yz plane at x = 0, opacity = 0.2, line width = 1pt]
      (0,0) arc (0:-90:-1);
    \draw[canvas is xz plane at y = 0, opacity = 0.2, line width = 1pt]
      (0,0) arc (0:-90:-1);

    \foreach \i in {0,...,10}
    \tdplotsetrotatedcoords{0}{0}{\i*36}
    \draw[tdplot_rotated_coords, thick,visible on=<\i>,
      canvas is zx plane at y = 0, line width = 1pt]
      (0,0) arc (90:0:1);

\end{tikzpicture}
\end{frame}

\end{document}

ImageMagick command to produce the animated gif:

convert -verbose -delay 12 -loop 0 -density 300 i.pdf o.gif
3
  • No, no! I was just amused by the typo in animated git.
    – cfr
    Jul 31, 2015 at 12:54
  • @cfr Sorry, I didn't get that right.
    – sergej
    Jul 31, 2015 at 13:32
  • I should remember that humour does not do well online. It was only a joke, albeit it not a very good one. You had animated git in place of animated gif. Two meanings of 'git': slang term for somebody obnoxious, or the version control system. I just found the idea of animating either amusing. I should probably have kept my amusement to myself.
    – cfr
    Jul 31, 2015 at 20:36
4
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}

\tdplotsetmaincoords{70}{20}     % point of view

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

 %draw black arc
  \draw[canvas is xy plane at z = 0, line width = 1pt]
    (0,0) arc (0:-90:-1);

 %draw rotated gray arcs (5°-steps)
  \foreach \rotStep in {5,10,15,...,355}{
    \tdplotsetrotatedcoords{0}{\rotStep}{0} 
        \draw[tdplot_rotated_coords, canvas is xy plane at z = 0, line width = 1pt, opacity = 0.2]
          (0,0) arc (0:-90:-1);
   }

  %draw the axes
  \draw[red,->] (0,0,0) -- (0,4,0) node[anchor=north]{$x$};
  \draw[blue,->]  (0,0,0) -- (0,0,-2) node[anchor=west]{$y$};
  \draw[blue,->] (0,0,0) -- (2,0,0) node[anchor=south]{$z$};

\end{tikzpicture}
\end{document}

enter image description here

With the help of Sergej, I achieved a solution for my problem using \tdplotsetrotatedcoords{}{}{}. The animated version is a cool feature by the way.

Thanks for your help! Nico

0

You must log in to answer this question.

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