tikz-3dplot: 특정 축을 중심으로 호 회전

tikz-3dplot: 특정 축을 중심으로 호 회전
    \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}

회전된 호

안녕하세요,

다음과 같은 문제가 있습니다. xz 평면의 검은색 호가 그려진 x축을 중심으로 회전하길 원합니다. 90° 회전 단계에만 도달했지만 회전 단계를 예를 들어 5°로 설정하고 싶습니다. 누구든지 그 문제를 해결하도록 도와줄 수 있나요?

고마워요, 니코

답변1

원점을 에 배치하여 코드를 단순화했습니다 (0,0,0).

다음을 사용하여 관점을 설정할 수 있습니다.

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

검정색 호 회전은 다음을 사용하여 설정할 수 있습니다.

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

여기에 이미지 설명을 입력하세요

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

애니메이션 버전(재미용):

여기에 이미지 설명을 입력하세요

코드:

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

애니메이션 GIF를 생성하는 ImageMagick 명령:

convert -verbose -delay 12 -loop 0 -density 300 i.pdf o.gif

답변2

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

여기에 이미지 설명을 입력하세요

Sergej의 도움으로 \tdplotsetrotatedcoords{}{}{}. 그런데 애니메이션 버전은 멋진 기능입니다.

당신의 도움을 주셔서 감사합니다! 니코

관련 정보