next up previous
Next: About this document ... Up: gg_param_nt Previous: gg_param_nt

3. Animated plots

First give the command
with(plots); to load the necessary routines.

Specifying the animated plot is easy: You simply include a third parameter, and it automatically changes with time when you run the animation. Example:

To plot $ P(t,u) = (t,u,\sin(t+v)\sin(u))$ for $ -\pi \leq t \leq \pi$ and $ -\pi \leq u \leq \pi$, where $ v$ changes with time from $ v=0$ to $ v=2 \pi$, type
animate3d([t,u,sin(t+v)*sin(u)],t=-Pi..Pi,u=-Pi..Pi,v=0..2*Pi);

First, you will see just the first frame, and then you will have to wait while Maple generates additional frames (not yet shown). Then on the Animate menu, select Play. This will play it once, probably too fast. You can slow it down by selecting another menu item. You can also set it to loop over and over by selecting the continuous menu item. Stop it by selecting Stop, which will have appeared on the Animate menu.

What is really happening is that Maple makes eight frames, while varying the third parameter ($ v$ in the example above).

In the example above, the range of the third parameter $ v$ has been chosen so that the last value of $ v$ gives the same plot as the first value, to have continuous plotting make sense. But then in continuous plotting, there is a resulting jerkiness when the first and last plots are played in succession! In other words, one plot is doubled. To fix that, use this trick:

animate3d([t,u,sin(t+v)*sin(u)],t=-Pi..Pi,u=-Pi..Pi,v=0..2*Pi*7/8);

Thus the eight plots are fractions $ 0, 1,\dots, \frac 78$ of the full range of $ v$, and the next plot 0 fits exactly into the sequence to make a smooth continuous animation.

If you have an animation where the third parameter does not finish where it starts, for example, a radius $ r$ goes from 0 to 1, then there is a trick to make it continuous so you can loop: First, realize that $ \cos v$ goes from 1 to $ -1$ and back as $ v$ goes from 0 to $ 2 \pi$. Therefore $ r = (1-\cos v)/2$ goes from 0 to 1 and back. Substitute this expression for $ r$ in your function to make a plot that can loop smoothly. Or if $ r$ is to go from 2 to 5 and back, you could use $ r = 2 + (5-2)(1-\cos
v)/2$.

Notice that $ v$ rather than $ t$ was used for the time-related parameter in the example above. It might be better to use $ r,s,t$ for parameters so $ t$ is time.


next up previous
Next: About this document ... Up: gg_param_nt Previous: gg_param_nt
Kirby A. Baker 2002-03-01