summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/animate/animate.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/animate/animate.tex')
-rw-r--r--Master/texmf-dist/doc/latex/animate/animate.tex298
1 files changed, 80 insertions, 218 deletions
diff --git a/Master/texmf-dist/doc/latex/animate/animate.tex b/Master/texmf-dist/doc/latex/animate/animate.tex
index 2524f23775e..4833f0a5deb 100644
--- a/Master/texmf-dist/doc/latex/animate/animate.tex
+++ b/Master/texmf-dist/doc/latex/animate/animate.tex
@@ -8,8 +8,8 @@
\frenchspacing
\usepackage[UKenglish]{babel}
\usepackage{pst-3dplot}
-\usepackage{pst-node,pst-plot,pst-tools,pst-text}
-\usepackage{animate}
+\usepackage{pst-node,pst-plot,pst-tools,pst-text,pst-ode}
+\usepackage{../animate}
\usepackage{media9}
\usepackage{intcalc}
\usepackage{graphicx}
@@ -69,11 +69,22 @@
\def\XeLaTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\LaTeX}
\def\pXepLaTeX{(X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}})\kern-.125em\LaTeX}
+\def\parsedate#1/#2/#3\relax{
+ \def\year{#1}
+ \def\month{#2}
+ \def\day{#3}
+}
+
\begin{document}
\title{The {\sffamily animate} Package}
+\begingroup
+\makeatletter
+\def\@anim@sanitize{}\def\@anim@endsanitize{}
+\expandafter\parsedate\@anim@version\relax %set current date to package date
+\makeatother
\author{Alexander Grahn \animategraphics[autoplay,loop,height=1.8ex]{8}{bye_}{0}{3}\protect\footnote{Animated GIF taken from \href{http://www.phpBB.com}{phpBB} forum software and burst into a set of EPS files using \href{http://www.imagemagick.org}{ImageMagick} before embedding. Animations may run slowly if viewed in the Adobe Reader browser plugin.}\\[1ex]\includegraphics[height=2.7ex]{mailto}}
\maketitle
-
+\endgroup
\begin{abstract}
\raggedright
@@ -182,6 +193,8 @@ By default, the animation is built frame by frame in the order of inclusion of t
\myparagraph*{Sets of graphics files}
All files of the sequence should exist and be consecutively numbered. (Exception to this rule is allowed in connection with the `\verb+every+' option, see below.) {\tt <file base\-name>} is the leftmost part of the file name that is common to all members of the sequence. \verb+<first>+ is the number of the first and \verb+<last>+ the number of the last file in the set. If \verb+<first>+ is greater than \verb+<last>+, files are embedded in reverse order. File names may be simply numbered, such as $0\dots99$. If there are leading zeros, make sure that all file numbers have the same number of digits, such as $0000\dots0099$, and that the \verb+<first>+ and \verb+<last>+ arguments are filled in accordingly.
+Command \verb+\graphicspath{}+ from the `graphicx' package can be used to specify directories to be browsed for graphics files.
+
No file name extension may be specified as a parameter. The possible file formats depend on the output driver being used. In the case of \LaTeX{}+\verb+dvips+, files with the `eps' extension are at first searched for, followed by `mps' (\MP-generated Postscript) and `ps'. With pdf\LaTeX{} the searching order is: (1)~`pdf', (2)~`mps', (3)~`png', (4)~`jpg', (5)~`jpeg', (6)~`jbig2', (7)~`jb2', (8)~`jp2'\footnotemark[1], (9)~`j2k'\footnotemark[1], (10)~`jpx'\footnotemark[1]\footnotetext[1]{JPEG2000 is not yet supported by pdf\TeX.} and with \XeLaTeX{} or \LaTeX{}+\verb+dvipdfmx+: (1)~`pdf', (2)~`mps', (3)~`eps', (4)~`ps', (5)~`png', (6)~`jpg', (7)~`jpeg', (8)~`bmp'. That is, files capable of storing vector graphics are found first. Make sure that all file names have \emph{lower case} extensions.
For example, given the sequence `frame\_5.png' through `frame\_50.png' from a possibly larger set that shall be used to build an animation running at 12 frames per second, the correct inclusion command would read
@@ -616,89 +629,23 @@ Fig.~\ref{fig:torus} is an inline graphics example adapted from \cite{gilg05}.
Another inline example, Fig.~\ref{fig:lorenz}, is an animation of the Lorenz Attractor. The Lorenz Attractor is a three-dimensional parametric curve whose coordinates are obtained by integrating the set of three ordinary differential equations
\begin{align*}
\frac{\mathrm{d}x}{\mathrm{d}t}& = \alpha (y-x)\\
- \frac{\mathrm{d}y}{\mathrm{d}t}& = x(\beta-z)\\
+ \frac{\mathrm{d}y}{\mathrm{d}t}& = x(\beta-z)-y\\
\frac{\mathrm{d}z}{\mathrm{d}t}& = x y - \gamma z
\end{align*}
-with respect to the independent parameter $t$. The shape of the attractor strongly depends on the values chosen for the coefficients $\alpha$, $\beta$ and $\gamma$ as well as on the initial conditions, that is, the coordinates $x_0$, $y_0$ and $z_0$ of the starting point of the curve. Here we use the values $\alpha=10$, $\beta=28$, $\gamma=8/3$ and the starting point $\mathbf{x}_0=(3,15,1)$.
+with respect to the independent parameter $t$. The shape of the attractor strongly depends on the values chosen for the coefficients $\alpha$, $\beta$ and $\gamma$ as well as on the initial conditions, that is, the coordinates $x_0$, $y_0$ and $z_0$ of the starting point of the curve. Here we use the values $\alpha=10$, $\beta=28$, $\gamma=8/3$ and the starting point $\mathbf{x}_0=(10,10,30)$.
-The right hand sides of the equations above are implemented in the Postscript procedure `\verb+lorenz+' which is passed to the macro \verb+\odesolve+. The latter implements the Runge-Kutta method for integrating sets of ordinary differential equations. Its core is also written in Postscript. Hence, the computation of the curve is performed by the Postscript interpreter while converting the PS document into PDF. The solution vectors $\mathbf{x}(t)$ are written to a text file subsequently read by the macro \verb+\parametricplotThreeD+ from the PSTricks package `pst-3dplot' in order to plot the curve. Note that the creation of intermediate files requires the Postscript interpreter to be run in unsafe mode. In the case of Ghostscript, option `\verb+-dNOSAFER+' must be passed to \verb+ps2pdf+. Feel free to copy the code of \verb+\odesolve+ verbatim in order to solve your own initial value problems.
+The right hand sides of the equations above are defined in the macro \verb+\lorenz+ as algebraic expressions. The initial value problem is solved by the macro \verb+\pstODEsolve+ from the PSTricks package `pst-ode' and plotted by the macro \verb+\parametricplotThreeD+ from the PSTricks package `pst-3dplot'.
A timeline file, written on-the-fly, is used to assemble the curve segments frame by frame to the growing attractor which, in turn, is put on top of the $x$-$y$-$z$ coordinate system. After the attractor has been completed, the transparency stack is cleared. Then, transparencies containing the complete curve and the coordinate system seen from different viewpoints are put in a row to produce the animated fly-around.
\begin{figure}[t]
\centering
-\makeatletter%
-\def\odesolve{\@ifstar{\@odesolve[append]}{\@odesolve}}%
-\newcommand{\@odesolve}[8][]{%
- \def\append{false}%
- \def\filemode{w}%
- \ifthenelse{\equal{#1}{append}}{%
- \def\append{true}%
- \def\filemode{a}}{}%
- \def\initcond{}%
- \ifthenelse{\equal{#7}{}}{}{%
- \def\initcond{/laststate [#7] def}%
- }%
- \pstVerb{%
- /statefile (#2) (\filemode) file def
- /outvect [#3] def
- /t #4 def
- /tEnd #5 def
- /dt tEnd t sub #6\space 1 sub div def % step size
- /dt2 dt 2 div def % half step size
- \initcond %set initial state vector
- /xlength laststate length def % number of equations
- /xlength1 xlength 1 add def % number of equations plus 1
- /ODESET { cvx exec #8 xlength array astore } def %system of ODEs
- /addvect { % [1 2 3] [4 5 6] addvect => [5 7 9]
- cvx exec xlength1 -1 roll {xlength1 -1 roll add} forall
- xlength array astore
- } def
- /mulvect { % [1 2 3] 4 mulvect => [4 8 12]
- /mul cvx 2 array astore cvx forall xlength array astore
- } def
- /divvect { % [4 8 12] 2 divvect => [2 4 6]
- /div cvx 2 array astore cvx forall xlength array astore
- } def
- /RK { % performs one Runge-Kutta integration step
- % [ state vector x(t) ] RK => [ state vector x(t + dt) ]
- dup ODESET /k0 exch def
- t dt2 add /t exch def
- dup k0 dt2 mulvect addvect ODESET /k1 exch def
- dup k1 dt2 mulvect addvect ODESET /k2 exch def
- t dt2 add /t exch def
- dup k2 dt mulvect addvect ODESET /k3 exch def
- k0 k1 2 mulvect addvect k2 2 mulvect addvect k3 addvect
- 6 divvect dt mulvect addvect
- } def
- /output { %output routine
- outvect {
- dup (t) eq {
- pop t 20 string cvs statefile exch writestring
- }{
- laststate exch get 20 string cvs statefile exch writestring
- } ifelse
- statefile (\space) writestring
- } forall
- statefile (\string\n) writestring
- } def
- \append\space not {output} if
- #6\space 1 sub {laststate RK /laststate exch def output} repeat
- statefile closefile
- }%
-}%
-\makeatother%
%
%Lorenz' set of differential equations
-\pstVerb{
- /lorenz {
- %get elements of current state vector
- /varz exch def /vary exch def /varx exch def
- %
- 10 vary varx sub mul %dx/dt
- varx 28 varz sub mul %dy/dt
- varx vary mul 8 3 div varz mul sub %dz/dt
- } def
+\def\lorenz{%
+ 10*(x[1]-x[0]) | %dx/dt
+ x[0]*(28-x[2]) - x[1] | %dy/dt
+ x[0]*x[1] - 8/3*x[2] %dz/dt
}%
%
%write timeline file
@@ -719,23 +666,32 @@ A timeline file, written on-the-fly, is used to assemble the curve segments fram
controls,poster=last,
begin={\begin{pspicture}(-39,-13)(39,60)},
end={\end{pspicture}}
-]{10}%
+]{10}
+ %coordinate axes
\psset{Alpha=120,Beta=20}%
\pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
- \newframe%
- \pstVerb{/laststate [3 15 1] def}% initial condition
- \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{% t0, t1
- \odesolve{lorenz.dat}{0 1 2}{\rtZero}{\rtOne}{26}{}{lorenz}%
- \pstVerb{/infile (lorenz.dat) (r) file def}%
- \parametricplotThreeD[plotstyle=line,xPlotpoints=26](0,0){infile 80 string readline pop cvx exec}%
+\newframe
+ \pstODEsetOrRestoreState{10 10 30} %initial condition
+ \multiframe{100}{i=0+1,rtZero=0+0.25,rtOne=0.25+0.25}{%
+ \pstODEsaveState{savedState}%
+ %compute attractor segments, stored in `lorenzXYZseg'
+ \pstODEsolve[algebraic]{lorenzXYZseg}{0 1 2}{\rtZero}{\rtOne}{26}{savedState}%
+ {\lorenz}%
+ %compute the whole attractor, stored in `lorenzXYZall', with the same stepping
+ \ifnum\i=0\relax%
+ \pstODEsolve[algebraic]{lorenzXYZall}{0 1 2}{\rtZero}{\rtOne}{26}{savedState}%
+ {\lorenz}%
+ \else%
+ \pstODEsolve[algebraic,append]{lorenzXYZall}{0 1 2}{\rtZero}{\rtOne}{26}%
+ {savedState}{\lorenz}%
+ \fi%
+ \listplotThreeD[plotstyle=line]{lorenzXYZseg}%
}%
- \newframe% required between two \multiframe
- \odesolve{lorenz.dat}{0 1 2}{0}{25}{2501}{3 15 1}{lorenz}%
- \multiframe{90}{rAlpha=116+-4}{%
+\newframe% required between two \multiframe
+ \multiframe{90}{rAlpha=116+-4}{% fly-around
\psset{Alpha=\rAlpha,Beta=20}%
\pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
- \pstVerb{/infile (lorenz.dat) (r) file def}%
- \parametricplotThreeD[plotstyle=line,xPlotpoints=2501](0,0){infile 80 string readline pop cvx exec}%
+ \listplotThreeD[plotstyle=line]{lorenzXYZall}%
}%
\end{animateinline}
\caption{}\label{fig:lorenz}
@@ -746,115 +702,16 @@ A timeline file, written on-the-fly, is used to assemble the curve segments fram
\documentclass{article}
\usepackage{multido}
\usepackage{pst-3dplot}
-\usepackage{pstricks-add}
+\usepackage{pst-ode}
\usepackage{animate}
-\makeatletter
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% odesolve
-%
-% LaTeX command for integrating systems of first order ODEs using the Runge-
-% Kutta method; values of the integration parameter `t' as well as the solution
-% (= state) vectors are written to a text file
-%
-% Usage:
-%
-% \odesolve{filename}{output vector}{ta}{tb}{nodes}{initial cond.}{function}
-% \odesolve*{filename}{output vector}{ta}{tb}{nodes}{initial cond.}{function}
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% #1: output filename for solution data
-% #2: output vector format, e. g. `(t) 0 1'; specifies which data to be written
-% to #1; (t) (parentheses required) writes integration parameter to the data
-% file, 0, 1, 2, etc. specify the elements of the state vector to be written
-% #3: start value of integration parameter (ta)
-% #4: end value of integration parameter (tb)
-% #5: number of output points (nodes), including ta and tb
-% #6: initial condition vector; if empty, use state vector from last \odesolve
-% invocation
-% #7: right hand side of ODE system; the function provided should pop the
-% elements of the current state vector from the operand stack and push the
-% first derivatives (right hand side of ODE system) back to it, the
-% integration parameter can be accessed using `t'
-%
-% \odesolve* --> computed data are appended to existing data file (arg. #1)
-% rather than overwriting it
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\odesolve{\@ifstar{\@odesolve[append]}{\@odesolve}}
-\newcommand{\@odesolve}[8][]{%
- \def\append{false}%
- \def\filemode{w}%
- \ifthenelse{\equal{#1}{append}}{%
- \def\append{true}%
- \def\filemode{a}}{}%
- \def\initcond{}%
- \ifthenelse{\equal{#7}{}}{}{%
- \def\initcond{/laststate [#7] def}%
- }%
- \pstVerb{%
- /statefile (#2) (\filemode) file def
- /outvect [#3] def
- /t #4 def
- /tEnd #5 def
- /dt tEnd t sub #6\space 1 sub div def % step size
- /dt2 dt 2 div def % half step size
- \initcond %set initial state vector
- /xlength laststate length def % number of equations
- /xlength1 xlength 1 add def % number of equations plus 1
- /ODESET { cvx exec #8 xlength array astore } def %system of ODEs
- /addvect { % [1 2 3] [4 5 6] addvect => [5 7 9]
- cvx exec xlength1 -1 roll {xlength1 -1 roll add} forall
- xlength array astore
- } def
- /mulvect { % [1 2 3] 4 mulvect => [4 8 12]
- /mul cvx 2 array astore cvx forall xlength array astore
- } def
- /divvect { % [4 8 12] 2 divvect => [2 4 6]
- /div cvx 2 array astore cvx forall xlength array astore
- } def
- /RK { % performs one Runge-Kutta integration step
- % [ state vector x(t) ] RK => [ state vector x(t + dt) ]
- dup ODESET /k0 exch def
- t dt2 add /t exch def
- dup k0 dt2 mulvect addvect ODESET /k1 exch def
- dup k1 dt2 mulvect addvect ODESET /k2 exch def
- t dt2 add /t exch def
- dup k2 dt mulvect addvect ODESET /k3 exch def
- k0 k1 2 mulvect addvect k2 2 mulvect addvect k3 addvect
- 6 divvect dt mulvect addvect
- } def
- /output { %output routine
- outvect {
- dup (t) eq {
- pop t 20 string cvs statefile exch writestring
- }{
- laststate exch get 20 string cvs statefile exch writestring
- } ifelse
- statefile (\space) writestring
- } forall
- statefile (\string\n) writestring
- } def
- \append\space not {output} if
- #6\space 1 sub {laststate RK /laststate exch def output} repeat
- statefile closefile
- }%
-}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\makeatother
-
\begin{document}
-%
-% Lorenz' set of differential equations
-\pstVerb{
- /lorenz {
- %get elements of current state vector
- /varz exch def /vary exch def /varx exch def
- %
- 10 vary varx sub mul %dx/dt
- varx 28 varz sub mul %dy/dt
- varx vary mul 8 3 div varz mul sub %dz/dt
- } def
+
+%Lorenz' set of differential equations
+\def\lorenz{%
+ 10*(x[1]-x[0]) | %dx/dt
+ x[0]*(28-x[2]) - x[1] | %dy/dt
+ x[0]*x[1] - 8/3*x[2] %dz/dt
}%
%
%write timeline file
@@ -869,35 +726,40 @@ A timeline file, written on-the-fly, is used to assemble the curve segments fram
}%
\immediate\closeout\OutFile%
%
-\begin{center}
\psset{unit=0.155,linewidth=0.5pt}%
\begin{animateinline}[
timeline=lorenz.tln,
controls,poster=last,
begin={\begin{pspicture}(-39,-13)(39,60)},
end={\end{pspicture}}
-]{10}%
+]{10}
+ %coordinate axes
\psset{Alpha=120,Beta=20}%
\pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
-\newframe%
- \pstVerb{/laststate [3 15 1] def}%
- \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{% t0, t1
- \odesolve{lorenz.dat}{0 1 2}{\rtZero}{\rtOne}{26}{}{lorenz}%
- \pstVerb{/infile (lorenz.dat) (r) file def}%
- \parametricplotThreeD[%
- plotstyle=line,xPlotpoints=26](0,0){infile 80 string readline pop cvx exec}%
+\newframe
+ \pstODEsetOrRestoreState{10 10 30} %initial condition
+ \multiframe{100}{i=0+1,rtZero=0+0.25,rtOne=0.25+0.25}{%
+ \pstODEsaveState{savedState}%
+ %compute attractor segments, stored in `lorenzXYZseg'
+ \pstODEsolve[algebraic]{lorenzXYZseg}{0 1 2}{\rtZero}{\rtOne}{26}{savedState}%
+ {\lorenz}%
+ %compute the whole attractor, stored in `lorenzXYZall', with the same stepping
+ \ifnum\i=0\relax%
+ \pstODEsolve[algebraic]{lorenzXYZall}{0 1 2}{\rtZero}{\rtOne}{26}{savedState}%
+ {\lorenz}%
+ \else%
+ \pstODEsolve[algebraic,append]{lorenzXYZall}{0 1 2}{\rtZero}{\rtOne}{26}%
+ {savedState}{\lorenz}%
+ \fi%
+ \listplotThreeD[plotstyle=line]{lorenzXYZseg}%
}%
-\newframe%
- \odesolve{lorenz.dat}{0 1 2}{0}{25}{2501}{3 15 1}{lorenz}%
- \multiframe{90}{rAlpha=116+-4}{%
+\newframe% required between two \multiframe
+ \multiframe{90}{rAlpha=116+-4}{% fly-around
\psset{Alpha=\rAlpha,Beta=20}%
\pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]%
- \pstVerb{/infile (lorenz.dat) (r) file def}%
- \parametricplotThreeD[%
- plotstyle=line,xPlotpoints=2501](0,0){infile 80 string readline pop cvx exec}%
+ \listplotThreeD[plotstyle=line]{lorenzXYZall}%
}%
\end{animateinline}
-\end{center}
\end{document}
\end{verbatim}
@@ -908,9 +770,9 @@ The last inline example in Fig.~\ref{fig:metronome} is a ticking metronome writt
\centering
\begin{VerbatimOut}{files/pstmetronome.tex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% animated metronome
+% animated metronome
% this code is based to 99.9 percent on the work by Manuel Luque
-% (pstricks.blogspot.com)
+% (pstricks.blogspot.com)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\pst@addfams{pst-metronome}
@@ -1169,7 +1031,7 @@ dt dt Tm nT mul { % pop
::25
::26: annotRM['click'].callAS('play');
\end{VerbatimOut}
-%sound inclusion: click.mp3
+%sound inclusion: click.mp3
\includemedia[
label=click,
addresource=click.mp3,
@@ -1237,17 +1099,17 @@ dt dt Tm nT mul { % pop
begin{document}
\begin{center}
- %sound inclusion: click.mp3
+ %sound inclusion: click.mp3
\includemedia[
label=click,
addresource=click.mp3,
activate=pageopen,
flashvars={source=click.mp3}
]{}{APlayer.swf}%
-
+
%loading metronome macros from external file
\input{files/pstmetronome}
-
+
%animated metronome
\begin{animateinline}[
controls,
@@ -1292,7 +1154,7 @@ begin{document}
Note that the name of the Ghostscript executable may vary between operating systems (e.\,g. `{\tt gswin32c.exe}' on Win/DOS).
- \item Animations with complex graphics and/or many frames may cause \LaTeX{} to fail with a `\verb+TeX capacity exceeded+' error. The following steps should fix most of the memory related problems.
+ \item\hypertarget{dest:mem}{} Animations with complex graphics and/or many frames may cause \LaTeX{} to fail with a `\verb+TeX capacity exceeded+' error. The following steps should fix most of the memory related problems.
MiK\TeX:
\begin{enumerate}
@@ -1300,7 +1162,7 @@ Note that the name of the Ghostscript executable may vary between operating syst
\item\label{item:firststep} At the DOS prompt, enter\\
{\tt initexmf -{}-edit-config-file=latex}
\item Type\\
- {\tt main\_memory=10000000}\\
+ {\tt main\_memory=12000000}\\
into the editor window that opens, save the file and quit the editor.
\item\label{item:laststep} To rebuild the format, enter\\
{\tt initexmf -{}-dump=latex}