Re: Controlling display of frames in a movie

• To: mathgroup at smc.vnet.net
• Subject: [mg73406] Re: Controlling display of frames in a movie
• From: "dimitris" <dimmechan at yahoo.com>
• Date: Thu, 15 Feb 2007 05:08:11 -0500 (EST)
• References: <equnlk\$ih5\$1@smc.vnet.net>

```Below it is a very instructive message by David Park which appeared in
private communication with him
a long time ago.
Since it well-written and informative I don't make any modifications.
I think you will find it very useful for your needs.

(*My original query was about delta sequences and animation of them*)
---------------------------------------------------------------------------=
----------------------------

(*reply od David Park*)
---------------------------------

Here is your animation.

Needs["Graphics`"]

delta[n_][x_] := n/(Sqrt[Pi]/E^((-n^2)*x^2))

frame[n_] :=
Plot[delta[n][x], {x, -2, 2},
PlotRange -> {-0.1, 6.1},
Frame -> True,
PlotLabel ->
SequenceForm[delta["n"][x], ", n =",
NumberForm[n, {4, 2}, NumberPadding -> {" ", "0"}]],
ImageSize -> {800, 500}];

Animate[frame[n], {n, 1, 10, 0.25}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.5];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -
>
0=2E1,
AnimationDirection -> ForwardBackward]}]

I usually like to keep the 'parameters' separate from the 'variable'
in
the
definition of delta, although in this case it wouldn't matter. (The
extra
brackets are called 'subvalues'.)

In making animations I like to define a frame function that plots one
frame
of the animation and then use the Animate statement (from
Graphics`Animation`) to actually carry out the animation. Then I can
test
individual frames and make changes before doing the entire animation.

In making an animation such as this, it is ALWAYS necessary to
specify
a
specific PlotRange. You can't use All. This is because you must have
the
same PlotRange for all frames and Mathematica usually tries to pick
the
'most interesting part', and All will not be the same for all frames.

When putting n on the plot, it is usually necessary to use NumberForm
with a
NumberPadding specification so the number will always fit into the
same
space. Otherwise you will get a jumping effect for different frames.

In the Animate statement I have added commands that select the
generated
frames, close them up and start the animation. For those who have
DrawGraphics these commands can be pasted in from the DrawGraphics
palette.

In viewing an animation like this it is useful to know that you can
use
the
keyboard to step through the animation. This is often the best way to
view
an animation.

1) The up/down arrow keys will allow you to advance one frame at a
time.
2) The right/left arrow keys will put in animation into the forward or
backward direction.
3) The number keys will control the speed of the animation.
4) 'p' will pause and restart the animation.
5) 'c' will restart the animation in the forward-backward mode.

---------------------------------------------------------------------------=
------------------
(*end of David Park's message*)

Best Regards
Dimitrs

=CF/=C7 Alain Cochard =DD=E3=F1=E1=F8=E5:
> Hello.  I'm trying to generate a kind of animation for which I control
> the display of the next frame.  In other words I'm trying to find the
> Mathematica equivalent to the following script:
>
>    x=[1 2 3] ;
>    for n=1:4
>      f = x.^n ;
>      plot(x,f)
>      pause
>    end
>
> 'x' is the vector {1,2,3}; 'f' is another vector of same length (here
> obtained from x).  'plot(x,f)' simply plots f as a function of x, and
> then the 'pause' statement causes the loop to stop and wait for the
> user to strike any key before continuing, hence before plotting the
> next curve.
>
> The natural way would seem to be using ShowAnimation, but I didn't
> find a way to control the occurrence of the next frame.
>
> Unless I'm missing something, using the basic (List)Plot command does
> not seem to be appropriate in view of the time it takes for the window
> to pop up --at least in the text based environment-- especially for
> use on a remote computer.
>
> Besides, I still wouldn't know how to close a window and initiate the
> next.
>
> Any hint?
> Thanks in advance,
> Alain

```

• Prev by Date: Re: RandomArray from user defined distribution?
• Next by Date: Dotted Lines at Discontinuities 2
• Previous by thread: Re: Controlling display of frames in a movie
• Next by thread: Removing constant multiples from polynomials