27 January 2006

How to Create an Animation  of an Orbiting Object

Jim Hannon

Norman Sperling suggested the development of computer astronomical animations in The Sperling Files: Creating New Astronomical Computer Graphics and Animations (The Citizen Scientist, 13 January 2006). Here I suggest a program that is useful for making at least some of the animations he suggests and for many more illustrating scientific principals.

The program is POVRay. This program is a very powerful method of making images and animations based on equations and computer programming-like commands. Have a look at some of the truly awesome artwork at the POVRay web site. Another really neat feature is that the program is free.

POVRay works by tracing what happens to the photons emitted by the light source(s) when they strike objects in a scene. This way shadows and reflections are accurately depicted in the image without having to program them. To see how POVRay would work for an astronomical animation, I programmed a simple spherical object orbiting another in a circular orbit. Here is the code for the entire animated image:

#include "colors.inc"
background { color Black }
camera {
location <0, 2.6, -4>
look_at <0, 1, 2>
}
sphere {
<0, 1, 2>, 0.5
texture {
pigment { color Yellow }
}
}
sphere {
<0, 1, 2>, 0.2
texture {
pigment { color Green }
}
translate<2.5*cos(2*pi*clock),0,2.5*sin(2*pi*clock)>

}
light_source { <8, 2, -12> color White}

First, an include file lets you describe simple colors with their name rather than specifying their RGB values.

The background color is set to black. It is outer space.

A camera location and direction are then specified. The coordinates are X,Y,Z. X is left to right, Y is down to up and Z is in to out on the screen. The units on the coordinates are arbitrary, and you can use any scale you want.

Next, the central planet or sphere is described in terms of its location and color. Then the orbiting moon is described. It is placed at the same location as the planet and then translated by the equations of a circle to its "orbit."

The last statement places the light source and describes its color. You can insert some background "stars" by placing various light sources behind the existing scene.

The program will render the image multiple times by incrementing the variable "clock." I chose to make 60 images for one orbit of the moon. What you end up with is 60 bmp image files of the scene. Figure simple50.gifxx is one image from the set that shows the shadow of the moon on the planet.

I then used a shareware program written by a friend of mine called PolyView to convert the bmp files to gif files and then to an animated gif file. Figure 2 shows the resulting animation.

For this article I chose to make an animated gif from the bmp images, because I knew how to do it and the animated gif is compatible with web browsers. Once you have the bmp images, it is possible to make any sort of computer animation file, including an MPEG-2 video with sound. I have arranged the light source (sun) to be nearly in the same plane as the orbit, so you can see both types of eclipse as the moon orbits. You can transform any of the parameters in the program into variables to make it easy to change the conditions that make the image.


 

Figure 1. Single frame from a POVRay program that animates the orbit of a simulated object around another object.

 

Figure 2. Animation of the orbit of a simulated object around another object. The animation was made using POVRay, a freeware program.

 

   
Copyright 2005 by Society for Amateur Scientists