animate - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Graphics : 2-D : animate

plots

  

animate

  

create a 2-D or 3-D animation on one parameter

 

Calling Sequence

Parameters

Options

Description

Examples

Calling Sequence

animate(plotcommand, plotargs, t=a..b, options)

animate(plotcommand, plotargs, t=L, options)

Parameters

plotcommand

-

Maple procedure that generates a 2-D or 3-D plot or plot objects

plotargs

-

list of arguments to the plot command

t

-

name of parameter on which the animation is made

a, b

-

real constants giving the range of the animation

L

-

list of values

options

-

(optional) equation(s) of the form option=value; specify options for the animate command or the plot command

Options

• 

background : color, image; accepts a color or image as the background of the animation. The default is NULL.

• 

digits : posint; specifies the number of decimal digits for the parameter value. The default is 5.

• 

frames : posint; specifies the number of frames in the animation. The default is 25.

• 

paraminfo : truefalse; generates the parameter value in the title for each frame. The default is true.

• 

trace : nonnegint or list; the number of previous frames to be kept in the animation, or a list specifying the frames to show. The default is 0, meaning that no trace is shown.

Description

• 

The animate command can be used to generate an animation on one parameter for any Maple plot command, both 2-D and 3-D.  For example, the following generates an animation of the sine curve Asinx on the amplitude A.

plots[animate]( plot, [A*sin(x), x=0..10], A=0..2 );

  

This command creates an animation with 25 frames.

  

To run the animation using the worksheet interface:

1. 

Click the plot. The plot toolbar is displayed.

2. 

In the toolbar, click the Play button.

  

Alternatively, right-click (Control-click, on Mac) the plot to display the context menu.  Select Animation > Play.

• 

In the first calling sequence, an animation with 25 frames is created, using 25 values for the animation parameter A chosen to be as uniformly spaced as possible on the range a..b. In the second calling sequence, the given list of values is used for frames of the animation.

• 

The first input, plotcommand is the Maple plotting command. It must return a Maple 2-D or 3-D plot. The second input, plotargs, is a list of arguments for plotcommand. To plot the sine function for two different frequencies, you can use:

plot( sin(2*x), x=-Pi..Pi, thickness=2 );

plot( sin(3*x), x=-Pi..Pi, thickness=2 );

• 

To convert this to an animation on the frequency, put the above arguments to the plot command in a list as follows.

plots[animate]( plot, [sin(A*x), x=-Pi..Pi, thickness=2], A=1..5 );

• 

To animate a curve being traced out in time, make the domain parameter(s), x in the above example, depend on the animation parameter.  For example, here is a sine curve being traced out in time t.

plots[animate]( plot, [sin(t), t=0..x], x=0..4*Pi );

• 

Animations in 3-D are similarly obtained.  For example:

plots[animate]( plot3d, [sin(A)*(x^2+y^2), x=-2..2, y=-2..2], A=0..2*Pi );

• 

The remaining arguments to the animate command are interpreted as options.  They are equations of the form option=value. The options described below are specific to the animate command. Other options, such as scaling=constrained, are passed on the to plots[display] command.

• 

By default, the animate command generates 25 frames equally spaced on the animation parameter interval A=a..b.  The optional argument frames=n specifies that the animation is to have n frames.

• 

By default, the numerical value of the animation parameter A is displayed to 5 significant digits for each frame in the animation in the title region of the plot.  The optional argument paraminfo=false turns this information off.  The optional argument digits=n can be used to display a different number of significant digits.

• 

The background=p option accepts a color or image as the background of the animation, as described in the plot/options help page. With the animate command, additional values for p are allowed. The value of p can be a PLOT or PLOT3D object (the output of a 2-D or 3-D plotting command) or a list of such objects. In the latter case, the plots[display] command is called to combine the plot structures into a single background plot. The value of p can also be a numerical value, in which case the plot generated by plotcommand for A=p is used for the background.

• 

The trace=n option specifies that a number of previous frames of the animation be kept visible. When n is a positive integer, n frames, as uniformly spaced in the animation range as possible, are displayed in all frames after their initial display. Thus, the final frame of the animation displays n+1 frames. For example, if the number of frames is 25 and n=5, then frames 1, 6, 11, 15, and 20 display in subsequent frames.

  

When n is a list of integers, then the frames in those positions are the frames that remain visible. Each integer in n must be no larger than the maximum number of frames.

  

The default is n=0, that is, no trace is shown.

• 

If each frame in the animation must contain two or more different plots, write a Maple procedure that creates each frame and animate that procedure.  See the last example in the Examples section below.

• 

To construct an animation sequence from existing plots, use the plots[display] function with the insequence option. This is what the animate command does.

• 

For information on viewing animations, see Overview of Animation Menu.

  

Note: You can save animations as an animated GIF file. For more information on producing GIF files, see plot/device.

Examples

To play an animation in this help page, right-click (Control-click, on Mac) the plot to display the context menu.  Select Animation > Play.

The first few examples are for animating a curve or surface on a parameter.

withplots:

animateplot,Ax2,x=4..4,A=3..3

animateplot,Ax2,x=4..4,A=3..3,trace=5,frames=50

animateplot,Ax2,x=4..4,A=3..3,trace=30,35,40,45,50,frames=50

The next example shows how to do this in 3 dimensions.

animateplot3d,Ax2+y2,x=3..3,y=3..3,A=2..2,style=patchcontour

The next examples are of a circle and a hyperbola given implicitly as an equation. See the plots[implicitplot3d] command to generalize these to 3 dimensions.

animateimplicitplot,x2+y2=r2,x=3..3,y=3..3,r=1..3,scaling=constrained

animateimplicitplot,x2+Axyy2=1,x=2..2,y=3..3,A=2..2,scaling=constrained

The next few examples are for animating a curve in 2 or 3 dimensions in time. Here is a sine wave and a damped sine wave animated in time.

animateplot,sint,sintexpt5,t=0..x,x=0..6π,frames=50

The following is a circle traced out using its trigonometric parametrization and its rational parametrization.  The latter does not result in a uniform motion.

animateplot,cost,sint,t=0..A,A=0..2π,scaling=constrained,frames=50

animateplot,1t21+t2,2t1+t2,t=10..A,A=10..10,scaling=constrained,frames=50,view=1..1,1..1

Here is a curve in 3-D space defined parametrically.

optsthickness=5,numpoints=100,color=black:

animatespacecurve,cost,sint,2+sinAt,t=0..20,opts,A=0..2π

The following example has a surface as the background and a curve traced on the surface.  The background frame is a 3-D plot of the surface.  The curve is a heavy black line.

Bplot3d1x2y2,x=1..1,y=1..1,style=patchcontour:

optsthickness=5,color=black:

animatespacecurve,t,t,12t2,t=1..A,opts,A=1..1,frames=11,background=B

The remaining examples show animations of objects in time. The first is an illustration of simple harmonic motion. We show a blue ball moving up and down in two dimensions. In the example, each frame is defined by a Maple procedure ball.

ball := proc(x,y) plots[pointplot]([[x,y]],color=blue,symbol=solidcircle,symbolsize=40) end proc:

animateball,0,sint,t=0..4π,scaling=constrained,frames=100

To roll the ball along the sine wave, make the sine wave the background frame and animate a ball along it, or leave a trace of the ball.

sinewaveplotsinx,x=0..4π:

animateball,t,sint,t=0..4π,frames=50,background=sinewave,scaling=constrained

animateball,t,sint,t=0..4π,frames=50,trace=10,scaling=constrained

This final example contains several objects in the animation.

F := proc(t)
plottools[line]([-2,0], [cos(t)-2, sin(t)], color=blue),
plottools[line]([cos(t)-2, sin(t)], [t, sin(t)], color=blue),
plot(sin(x), x=0..t, view=[-3..7, -5..5]);
end proc:

animateF,θ,θ=0..2π,background=plotcost2,sint,t=0..2π,scaling=constrained,axes=none

See Also

Animate Toolbar

Overview of Animation Menu

plot

plot/function

plot/options

plot/parametric

plot/range

plot/structure

plot3d

plot3d/viewpoint

plots

plots/animatecurve

plots/polarplot