1

I know that it is possible to animate content inside a Beamer (and generally a LaTeX document) using different package movie9, animate, etc. But I would like to include a dynamic model like this one :

Dynamic model in LaTeX

Look at the slider at the bottom : it updates the dynamic model just above it (following physics rules, on the right by the way, given to it but whatever).

I would like to know how the author did it. Could you give please me your ways of doing it (involving code or not).

1 Answers1

3

This is a code for the rotating induction machine field, it can be helpful to understand how to include equations on animations. You can use one sinusoidal equation to represent the vectors. If you want the exact animation, you need the spring shape. If think there is a \draw command for the spring shape, you just need to change the position of the circles and link the spring between them.

\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}
  • All the answers that everybody gave are not dynamic in the way that I showed you: control during presentation over a parameter influencing the model's behavior. – Le Duc Banal Oct 19 '16 at 07:12