prev index next 
Animation 
 POV-Ray Tips, 
 Tricks, and Techniques
Animation Math? 
 
Dan is perplexed: I need some information. I have read the POV-Ray docs and I am trying to get the hang of the animation capabilities in POV-Ray but I don't understand the math involved.  Could someone give me some guidance as to where to look or what kind of math is involved (I have looked at some of the books in the bibliography of the docs and I am even more perplexed) any help would be appreciated! 
 
Chris Colefax patiently answers:
POV-Ray animation is really very simple when you get down to it: the hard part is working out how to use the POV-Ray animation system to create your own animations. 

Basically the animation is produced by taking a scene and having certain things within the scene change over time: this could be objects changing colour, or moving, or the camera moving, or whatever.  Then you get POV-Ray to create a whole series of pictures, each showing the scene at a particular point in time.  You put the pictures together with another program, and voila! you have an animation. 

With other programs you usually have to create a whole series of keyframes, and the program will work out what the picture should look like as it goes from one keyframe to another.  With POV-Ray, all animation is handled by way of the clock variable.  This is simply a value that changes as you progress through the animation.  By default, the clock starts at 0 and finishes at 1. The frames in between the first and last use a clock somewhere between 0 and 1.  For example, if you have an eleven frame animation, the clock values look like this: 

  Frame    Clock 
     1           0 
     2          .1 
     3          .2 
     4          .3 
     5          .4 
     6          .5 
     7          .6 
     8          .7 
     9          .8 
    10         .9 
    11          1 

If you had more frames, then the change in the clock between each frame would be smaller (equal to 1 / (Number of Frames - 1)).  You can then use the clock variable in different functions and statements to cause changes in the scene, eg: 

  sphere {<5, 0, 0>, 1 rotate y*360*clock} 

would create a sphere that rotated about the y-axis (in frame 1 this would be the same as rotate y*0, in frame 6 this would be rotate y*360*.5 or y*180, and in frame 11 this would be rotate y*360*1 or rotate y*0 again).  If you want non-linear motion (ie. rather than starting at 0 and finishing at 1) you can modify the clock variable with something like this: 

  sphere {<0, 0, 0>, 1 translate <0, sin(clock*2*pi)*5, 0>} 

which would create a sphere that started at <0,0,0> then went up to <0,5,0>, down to <0,-5,0>, and back up to <0,0,0>. 

The above two examples are very simple, and because of the flexibility of POV-Ray's animation system it is almost impossible to try to cover all the possibilities.  The best thing to do is to think of what you want to create with your animation, and then come up with a way of doing this (and there is a way of doing almost everything!). 

So in answer to your original question, the math involved is simply: 

  clock = (Current Frame No. - 1) / (Total No. of Frames - 1) 

And for a cyclic animation the equation is: 

  clock = (Current Frame No. - 1) / Total No. of Frames 

This information would seem to me to be fairly useless when actually creating animations, but hopefully it helps to answer your question. 
 

  1