Some Maple animations |

Maple's `plots`

package has an animation
feature. For example, try

with(plots): animate(sin(x*t), x=-Pi..Pi, t=-5..5);

Click on the plot to select it, and then choose the `Play`
option on the `Animation` controls to see the movie. (There
is an `Animation` menu on the main menu bar; also you can
enable the `Context Bar` on the `View` menu, and then
pictorial controls will appear in the context bar when you select
the animated plot.)

It is also possible to create a movie "by hand" by splicing together a sequence of plots. For example, the following code mimics a screen saver that bounces a geometric figure around the screen.

**Warning.** Before you try this example, save your work and
close any unneeded windows. Since this example uses a lot of
colors and demands a lot of Maple's memory, it could possibly
crash your Maple session. (If that happens, try again with the
number of iterations set to `i=1..10`

instead of
`i=1..100`

.)

r1:=rand(-10..10): r2:=0.2*rand(6): p:=seq(plots[polygonplot]([[r1(),r1()],[r1(),r1()],[r1(),r1()]], color=COLOR(RGB, r2(), r2(), r2() ) ), i=1..100): plots[display]([p], insequence=true, axes=none, title="Moving Triangles", titlefont=[TIMES,BOLD,72]);

If you cut and paste this code into a Maple session and execute it, you should get a plot that looks something like the figure. When you start the animation playing, you should see randomly colored triangles move around the window.

Explanation: Maple's `rand`

command is a pseudo-random
number generator. The command `rand(-10..10)`

defines a
procedure to generate a random integer between *-10* and
*10*, so the `polygonplot`

command above makes a triangle
whose vertices are at random integral points within a *20* by
*20* square. The command `rand(6)`

defines a procedure to
generate a random integer between *0* and *5* inclusive, so
the color instruction above generates a color with a random
mixture of Red, Green, and Blue in the standard
*216*-node color cube. The whole
procedure generates a sequence of *100* randomly placed
triangles with random colors, and the `insequence=true`

command produces the animation.

**Exercise**

Reproduce the Math 696 logo by using a Maple animation.

The Math 696 course pages were last modified April 5, 2005.

These pages are copyright © 1995-2005 by Harold P. Boas. All rights reserved.

Some Maple animations |