答案1
这是旋转感应电机领域的代码,它有助于理解如何在动画中包含方程式。您可以使用一个正弦方程来表示矢量。如果您想要精确的动画,则需要弹簧形状。如果您认为有\draw
弹簧形状的命令,则只需更改圆圈的位置并将弹簧连接在它们之间即可。
\documentclass[compress]{beamer}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgf,tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{frame}[fragile]{\secname}{\subsecname}
\begin{center}
\newcounter{angle}
\setcounter{angle}{0}
\begin{animateinline}[loop, poster = first, controls]{30}
\whiledo{\theangle<359}
{
\begin{tikzpicture}
\pgfmathsetmacro{\b}{75}
\pgfmathsetmacro{\a}{15}
\pgfmathsetmacro{\R}{2}
\pgfmathsetmacro{\RR}{3}
\pgfmathsetmacro{\r}{1}
\pgfmathsetmacro{\P}{\R*tan(\b)}
\pgfmathsetmacro{\Q}{\R/cos(\b)}
\pgfmathsetmacro{\p}{\r/tan(\a)}
\pgfmathsetmacro{\q}{\r/sin(\a)}
\pgfmathsetmacro{\rt}{sqrt(3)}
\pgfmathsetmacro{\sa}{sin(\theangle)}
\pgfmathsetmacro{\ca}{cos(\theangle)}
\pgfmathsetmacro{\sb}{sin(\theangle + 120)}
\pgfmathsetmacro{\cb}{cos(\theangle + 120)}
\pgfmathsetmacro{\sc}{sin(\theangle + 240)}
\pgfmathsetmacro{\cc}{cos(\theangle + 240)}
% Definitions
\newcommand{\Cross}{$\mathbin{\tikz [x=1.4ex,y=1.4ex,line width=.2ex] \draw (0,0) -- (1,1) (0,1) -- (1,0);}$}
% Armature
\draw (0,0) circle (\RR);
\fill[color=gray!40] (0,0) circle (\RR);
\draw[line width=2mm, white] (0,0) circle (.75*\RR);
%
\draw [line width=.2ex,color=red] (0,.9*\RR) circle (.2) node[red]{\Cross};
\draw [line width=.2ex,color=red] (0,-.9*\RR) circle (.2);
\filldraw[very thick, color=white!50!red, inner color=red,outer color=white!50!red] (0,-.9*\RR) circle (.1);
\draw [line width=.2ex,color=blue] (-\rt*.45*\RR,-.45*\RR) circle (.2) node[blue]{\Cross};
\draw [line width=.2ex,color=blue] (\rt*.45*\RR,.45*\RR) circle (.2);
\filldraw[very thick, color=white!50!blue, inner color=blue,outer color=white!50!blue] (\rt*.45*\RR,.45*\RR) circle (.1);
\draw [line width=.2ex,color=green] (\rt*.45*\RR,-.45*\RR) circle (.2) node[green]{\Cross};
\draw [line width=.2ex,color=green] (-\rt*.45*\RR,.45*\RR) circle (.2);
\filldraw[very thick, color=white!50!green, inner color=green,outer color=white!50!green] (-\rt*.45*\RR,.45*\RR) circle (.1);
\draw[ultra thick,black,->] (0,0) -- (-.45*\R*\sc-.45*\R*\sb+.9*\R*\sa,-\rt*.45*\R*\sb+\rt*.45*\R*\sc);
\draw[thick,red,->] (0,0) -- (.9*\R*\sa,0);
\draw[thick,green,->] (0,0) -- (-.45*\R*\sb,-\rt*.45*\R*\sb);
\draw[thick,blue,->] (0,0) -- (-.45*\R*\sc,\rt*.45*\R*\sc);
\end{tikzpicture}
\stepcounter{angle}
\ifthenelse{\theangle<359}
{
\newframe
}
{
\end{animateinline}
}
}
\end{center}
\end{frame}
\end{document}