두 축을 중심으로 원을 회전하는 방법은 무엇입니까?

두 축을 중심으로 원을 회전하는 방법은 무엇입니까?

두 축을 중심으로 원을 회전하려고 합니다. 원은 빨간색 벡터에 수직으로 배치되어야 합니다.

암호:

\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % xyz axes
    \draw[thick,->] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,5) node[anchor=north west]{$z$};
    % vector
    \draw[->,red] (0,0,0) -- (4,4,4);
    % center of circle
    \fill (3,3,3) circle (1pt);
    % circle
    \draw (3,3,3) circle (3); % rotation?
\end{tikzpicture}
\end{document}

산출:

예시 사진

빨간색 벡터와 원이 서로 수직이 되도록 원을 회전시키는 방법을 알고 싶습니다. 제 생각에는 y축을 중심으로 45° 회전하고 z축을 중심으로 45° 회전하는 것 같은데 tikz를 사용하여 이를 어떻게 실현할 수 있나요?

답변1

나는 사용하는 것이 좋습니다tikz-3dplot 만약에TikZ는 2D로 그리도록 설계된 패키지로 3D를 가짜로 만드는 데 필요한 많은 계산을 처리하므로 TikZ를 정말로 사용하고 싶을 것입니다.

예를 들어:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{110}
\tdplotsetrotatedcoords{180}{-90}{-90}
\begin{tikzpicture}[tdplot_main_coords]
  \begin{scope}[tdplot_rotated_coords]
    \draw[thick,->] (0,0,0) -- (5,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (0,0,0) -- (0,5,0) node[anchor=north west]{$y$};
    \draw[thick,->] (0,0,0) -- (0,0,5) node[anchor=north west]{$z$};
    \draw[->,red] (0,0,0) -- (4,4,4);
    \path [fill] (3,3,3) coordinate (c) circle (1pt);
    \tdplotdrawarc[tdplot_rotated_coords]{(c)}{3}{0}{360}{}{}
  \end{scope}
\end{tikzpicture}
\end{document}

3D로 원

원에 음영을 주어 깊이감을 더 주고 싶다면 라이브러리를 사용 backgrounds하고 그리기 순서에 신경쓰면 됩니다. 예를 들어:

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{backgrounds}
\begin{document}
\tdplotsetmaincoords{70}{110}
\tdplotsetrotatedcoords{180}{-90}{-90}
\begin{tikzpicture}[tdplot_main_coords]
  \begin{scope}[tdplot_rotated_coords]
    \draw[thick,->] (0,0,0) coordinate (o) -- (5,0,0) node[anchor=north east]{$x$};
    \draw[thick,->] (o) -- (0,5,0) node[anchor=north west]{$y$};
    \draw[thick,->] (o) -- (0,0,5) node[anchor=north west]{$z$};
    \draw[red] (o) -- (3,3,3) coordinate (c);
    \path [fill] (c) circle (1pt);
    \begin{scope}[on background layer]
      \draw[->,red] (c) -- (4,4,4);
      \tdplotdrawarc[tdplot_rotated_coords, right color=blue!50!cyan, left color=blue!50!cyan!15!white, fill opacity=.25, postaction={top color=blue!50!cyan!15!white, bottom color=blue!50!cyan, fill opacity=.25}]{(c)}{3}{0}{360}{}{}
    \end{scope}
  \end{scope}
\end{tikzpicture}
\end{document}

음영처리된 버전

관련 정보