This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Add-ons / Standard Packages / Graphics  /

Graphics`Animation`

The ability to view dynamic effects with an animated sequence of graphics is often highly instructive. Such animations or movies can be generated by Mathematica on a number of computer systems such as the Macintosh and those running window systems such as SunView or the X Window System. 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. It is necessary to specify a value for the PlotRange option to ensure the same scale for each image.
  • 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 we only plot frames. To show the true proportions of the image we 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 which 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]


  • 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} ]











    The actual mechanics of animation depend upon the computer hardware, and only a brief description is given here. First, a RasterFunction is mapped as the DisplayFunction of each picture. This is done since it may be necessary to convert the image into a raster or some other intermediate form. On Silicon Graphics computers each frame is written as a 3-Script representation into a file, with the RasterFunction returning the filename. Alternatively, on other platforms, such as those running the X Window System or SunView, the RasterFunction has no effect upon the image other than options processing.
    The result of the RasterFunction is passed to an AnimationFunction that is responsible for cycling through the images. This depends upon the actual hardware that is present. On a Silicon Graphics computer, the AnimationFunction is an external program that accepts as input a sequence of filenames which are read. The resulting images are then animated. Under the X Window System and SunView the AnimationFunction writes the PostScript representation of each image into a single stream, the frames separated by special characters. This stream is sent to an external program that detects the special characters and renders the animation.
    On a computer with a notebook user interface, such as a Macintosh, NeXT, or Microsoft Windows-based computer, animations can be initiated by selecting a group of pictures and choosing the appropriate animation command in the front end. In this situation the utilities in this package are useful due to the tools they provide for the production of sequences of images.