This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Add-ons & Links / Standard Packages / Graphics /

Graphics`Animation`

The ability to view dynamic effects with an animated sequence of graphics is often highly instructive. The effect of motion is produced by displaying a sequence of frames in rapid succession.

A collection of useful routines is supplied in the package Graphics`Animation`. These provide tools for generating sequences of graphical images and displaying them on a variety of computer platforms.

The basic animation commands.

In this section animations are represented by arrays of the pictures. If you evaluate the Mathematica commands on your computer, each image will be displayed in rapid succession giving the appearance of motion.

This loads the package.

In[1]:= <<Graphics`Animation`

This gives an animation of sine waves with various frequencies.

In[2]:= Animate[Plot[Sin[n x], {x, 0, 2 Pi}, Axes -> False], {n, 1, 6, 1}]

This is an example of the use of ShowAnimation. To ensure the same scale for each image, it is necessary to specify a value for the PlotRange option.

In[3]:= ShowAnimation[Table[ Graphics[Line[{{0, 0}, {Cos[ t], Sin[t]}}], PlotRange -> {{-1, 1}, {-1, 1}}], {t, 0, 2Pi, Pi/8}]]

In addition to Animate and ShowAnimation, there are a number of other functions in the packages that are designed to make more specific types of pictures.

Animation of various plots.

For the purposes of display, only ten frames are plotted. To show the true proportions of the image, give the option AspectRatio the value Automatic and give explicit ranges for the PlotRange option to ensure that all the images have the same scale.

In[4]:= MovieParametricPlot[
{s Cos[2 Pi s + t], s Sin[2 Pi s + t]},
{s, 0, 4}, {t, 0, 2Pi},
Frames -> 10, Axes -> False,
AspectRatio -> Automatic,
PlotRange -> {{-4, 4}, {-4, 4}}]

Options to SpinShow.

SpinShow works by changing the viewpoint of the image. It generates a ViewPoint by rotating around a sphere of radius SpinDistance and shifting the result by the SpinOrigin. The actual rotation uses the first Euler angle with initial and final values determined by the settings of the SpinRange. A final amount of freedom is provided by the SpinTilt option that gives the and Euler angles of the rotation, which can give the rotation an amount of wobble.

This gives a parametric plot that will be animated.

In[5]:= g = ParametricPlot3D[
{x, Cos[t] Sin[x] , Sin[t] Sin[x]},
{x, -Pi, Pi}, {t, 0, 2Pi},
Axes -> False, Boxed -> False]

Out[6]=

This demonstrates the use of SpinShow on the parametric plot. Due to the symmetry of the image we need only animate half a cycle. The animation of the projection of a three-dimensional object often enhances the depth effect.

In[6]:= SpinShow[ g, Frames -> 10, SpinRange -> {0 Degree, 180 Degree} ]

On a computer with a notebook user interface for Mathematica, such as a Microsoft Windows, Macintosh, or X Windows-based computer, animations can be initiated by selecting a group of pictures and choosing the appropriate animation command in the front end. The utilities in this package can be used for the production of sequences of images.