我想制作一个动画,来展示这个盘子绕轴 oz 的旋转,我用了这个代码
\documentclass[border=5pt]{standalone}
\usepackage{tikz,tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{110}% deu angle $\theta_d$ atour de (x) et $\phi_d$ autour de (z)
\begin{tikzpicture}[tdplot_main_coords,scale=5]
\pgfmathsetmacro{\r}{.5}
\pgfmathsetmacro{\O}{45} % right ascension of ascending node [deg]
\pgfmathsetmacro{\i}{45} % inclination [deg]
\pgfmathsetmacro{\f}{45} % true anomaly [deg]
\coordinate (O) at (0,0,0);
\draw [thick,->] (O) -- (1.5,0,0) node[anchor=north east] {$x_0$};
\draw [thick,->] (O) -- (0,1,0) node[anchor=north west] {$y_0$};
\draw [thick,->] (O) -- (0,0,1.5) node[anchor=south] {$z_0$};
\fill[black, tdplot_main_coords] (0,0,0) circle (0.5pt)node[medway, anchor=-30]{$O$};
\tdplotsetthetaplanecoords{45}
\draw [thick,tdplot_rotated_coords,color=violet,->] (O) -- (1.5,0,0) node[anchor=north east] {$z$};
\draw [thick,tdplot_rotated_coords,color=violet,->] (O) -- (0,1.65,0) node[anchor=north west] {$x$};
\draw [thick,tdplot_rotated_coords,thick,dashed, color=violet,->] (O) -- (0,0,1) node[anchor=south] {$y$};
\draw [tdplot_rotated_coords, fill=yellow!20!gray] (O) -- (1,0,0)--(0,1,0)--cycle;
\tdplotdrawarc[thick, tdplot_main_coords, color=red, ->]{(0,0,0)}{\r}{0}{45}{anchor=105}{$\varphi$}
\tdplotdrawarc[thick, tdplot_main_coords, color=red, ->]{(0,0,0)}{\r}{90}{135}{anchor=180}{$\varphi$}
\end{tikzpicture}
\end{document}
以 3D 形式制作如上图所示的图形,但我还不熟悉使用 animate 包制作乳胶动画。 有人能帮我做这个吗?提前谢谢了。
答案1
只需按照 Ignasi 的链接并进行一些小调整即可
\documentclass[border=5pt]{standalone}
\usepackage{tikz,tikz-3dplot}
\usepackage{animate}
\begin{document}
\begin{animateinline}[loop, poster = first, controls]{24}
\multiframe{36}{iAngle=0+10}{
\tdplotsetmaincoords{70}{110}% deu angle $\theta_d$ atour de (x) et $\phi_d$ autour de (z)
\begin{tikzpicture}[tdplot_main_coords,scale=5]
\useasboundingbox[tdplot_screen_coords] (-2.3,-0.6) rectangle (2.3,2);
% adapted from https://tex.stackexchange.com/a/315853/121799
\pgfmathsetmacro{\r}{.5}
\pgfmathsetmacro{\O}{45} % right ascension of ascending node [deg]
\pgfmathsetmacro{\i}{45} % inclination [deg]
\pgfmathsetmacro{\f}{45} % true anomaly [deg]
\coordinate (O) at (0,0,0);
\draw [thick,->] (O) -- (1.5,0,0) node[anchor=north east] {$x_0$};
\draw [thick,->] (O) -- (0,1,0) node[anchor=north west] {$y_0$};
\draw [thick,->] (O) -- (0,0,1.5) node[anchor=south] {$z_0$};
\fill[black, tdplot_main_coords] (0,0,0) circle (0.5pt)node[midway, anchor=-30]{$O$};
\tdplotsetthetaplanecoords{\iAngle}
\draw [thick,tdplot_rotated_coords,color=violet,->] (O) -- (1.5,0,0) node[anchor=north east] {$z$};
\draw [thick,tdplot_rotated_coords,color=violet,->] (O) -- (0,1.65,0) node[anchor=north west] {$x$};
\draw [thick,tdplot_rotated_coords,thick,dashed, color=violet,->] (O) -- (0,0,1) node[anchor=south] {$y$};
\draw [tdplot_rotated_coords, fill=yellow!20!gray] (O) -- (1,0,0)--(0,1,0)--cycle;
\pgfmathtruncatemacro{\iBngle}{\iAngle+90}
\tdplotdrawarc[thick, tdplot_main_coords, color=red,->]{(0,0,0)}{\r}{0}{\iAngle}{anchor=105}{$\varphi$}
\tdplotdrawarc[thick, tdplot_main_coords, color=red, ->]{(0,0,0)}{\r}{90}{\iBngle}{anchor=180}{$\varphi$}
\end{tikzpicture}
}
\end{animateinline}
\end{document}