使用 tikz-3dplot 让两个圆盘绕 z 轴旋转?

使用 tikz-3dplot 让两个圆盘绕 z 轴旋转?

我是 tikz-3dplot 的初学者,我想画这个图 在此处输入图片描述

我使用了约翰·科米洛

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{patterns}% comme shading pour remplir une surface
\begin{document}

%\pgfmathsetmacro{\iAngle}{0}
\tdplotsetmaincoords{70}{110}
\foreach \iAngle in {1,10,...,360}
{
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (1.5,0,0) node[anchor=north]{$x$};
\draw[thick,->] (O) -- (0,1,0) node[anchor=west]{$y$};
\draw[thick,->] (O) -- (0,0,1) node[anchor=south]{$z$};
\draw[thick, opacity=0.3]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle;
\fill[pattern=dots,opacity=0.5]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle; 

  \fill[red,thick] (0,0,0.3) circle (0.3pt) node[left] {$O_1$};

\tdplotsetrotatedcoords{\iAngle}{0}{0}
\begin{scope}[tdplot_rotated_coords]
\draw[red,thick, ->]
 (0.6,0,0.3) -- (1.5,0,0.3) node[above] {$x_1$};
\draw[red,thick, ->]
 (0,0,0.3) -- (0,1,0.3) node[above] {$y_1$};
 \draw[thick, dashed, opacity=1]
  (0,0,0) -- (1.5,0,0);
   \fill[blue,thick] (0.6,0,0.3) circle (0.3pt) node[above] {$A_1$};
    \fill[blue,thick] (1.2,0,0.3) circle (0.3pt) node[above] {$A_2$};
    \draw[pattern=north west lines, pattern color=blue, opacity=0.5 ] (0.6,0,0.3) circle (0.7); 
     \draw[pattern=north west lines, pattern color=green, opacity=0.5 ] (1.2,0,0.3) circle (0.7);
      \draw[thick, dashed, opacity=1]
  (0,0,0.3) -- (0.6,0,0.3);
  \draw[thick, line, opacity=1]
  (0.6,0,0.3) -- (1.2,0,0.3);
\end{scope}
\end{tikzpicture}
}
\end{document}

我得到了下面的图,但是并不完整,

在此处输入图片描述

我如何修复动画中的主要坐标?

如何添加与磁盘相关的单位向量?

什么角度可以给我一个有趣的视角?

有人能帮助我完成这项工作吗

答案1

我删除了错误的line参数,制作了一个边界框,使得图片不会跳跃,最重要的是,使圆圈与旋转轴正交。

\documentclass[tikz]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{patterns}% comme shading pour remplir une surface
\begin{document}

\pgfmathsetmacro{\RelativeSpeed}{0.3}
\tdplotsetmaincoords{70}{110}
\foreach \iAngle in {1,5,...,360}
{
\begin{tikzpicture}[scale=5,tdplot_main_coords]
\useasboundingbox[tdplot_screen_coords] (-1.8,-1) rectangle (1.4,1.4);
\coordinate (O) at (0,0,0);
\draw[thick,->] (O) -- (1.5,0,0) node[anchor=north]{$x$};
\draw[thick,->] (O) -- (0,1,0) node[anchor=west]{$y$};
\draw[thick,->] (O) -- (0,0,1) node[anchor=south]{$z$};
\draw[thick, opacity=0.3]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle;
\fill[pattern=dots,opacity=0.5]
  (0,0,0) -- (1.5,0,0) -- (1.5,1,0) -- (0,1,0) -- cycle; 

  \fill[red,thick] (0,0,0.3) circle (0.3pt) node[left] {$O_1$};

\tdplotsetrotatedcoords{\iAngle}{00}{0}
\begin{scope}[tdplot_rotated_coords]
\draw[red,thick, ->]
 (0.6,0,0.3) -- (1.5,0,0.3) node[above] {$x_1$};
\draw[red,thick, ->]
 (0,0,0.3) -- (0,1,0.3) node[above] {$y_1$};
 \draw[thick, dashed, opacity=1]
  (0,0,0) -- (1.5,0,0);
   \coordinate[label=above:$A_1$] (A1) at (0.6,0,0.3);
   \coordinate[label=above:$A_2$] (A2) at (1.2,0,0.3);
   \fill[blue,thick] (A1) circle (0.3pt);
   \fill[blue,thick] (A2) circle (0.3pt);
\end{scope}
\tdplotsetrotatedcoords{\iAngle}{90}{0}
\begin{scope}[tdplot_rotated_coords]
    \draw[pattern=north west lines, pattern color=blue, opacity=0.5 ] (A1) circle (0.7); 
    \draw[pattern=north west lines, pattern color=green, opacity=0.5 ] (A2) circle (0.7);
    \pgfmathsetmacro{\jAngle}{\RelativeSpeed*\iAngle}
    \draw[-latex,blue] (A1) -- ++({-0.7*cos(\jAngle)},{0.7*sin(\jAngle)},0)node[right]{$y_1'$}; 
    \draw[-latex,blue] (A1) -- ++({0.7*sin(\jAngle)},{0.7*cos(\jAngle)},0)node[right]{$x_1'$};  
    \draw[-latex,green] (A2) -- ++(-0.7,0,0)node[right]{$y_2'$};    
    \draw[-latex,green] (A2) -- ++(0,0.7,0)node[right]{$x_2'$}; 
\end{scope}
\tdplotsetrotatedcoords{\iAngle}{00}{0}
\begin{scope}[tdplot_rotated_coords]
      \draw[thick, dashed, opacity=1]
  (0,0,0.3) -- (0.6,0,0.3);
  \draw[thick, -, opacity=1]
  (0.6,0,0.3) -- (1.2,0,0.3);
\end{scope}
\end{tikzpicture}
}
\end{document}

更新:我希望已经满足了您的要求。在此版本中,蓝色框架以大框架旋转速度的 30% 旋转。相对速度由参数设置\RelativeSpeed。您可以使用相同的技巧来旋转绿色框架,或以不同的速度旋转它。实际上,编写代码相当简单,但我却很难将 的 pdf 转换为动画 gif。(为什么这么复杂?为什么要花这么长时间?)因此,我渴望学习一种更有效的方法来做到这一点。

在此处输入图片描述

相关内容