Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
logo
    3D Animations with POV-Ray
        Some basics and examples on animations.
Italiano Italiano
Français français
Deutsch Deutsch
Home
- 3D Animations Gallery
- POV-Ray Tutorial

  3D Animation Tutorial
   Index of Content
  0. Basic Knowledge
     1. Basic Example
     2. Example 2
     3. Images to Animated Gif
     4. From Images to Video
     5. Basic Terms
     6. Animation Commands  
  I. Cyclic Animations
     1. Rotating Objects
     1.2. Planets in Orbit
     1.3. Clock Animation
     2. Rotating Camera
     2.1. Straight Moving Camera
     3. Western Wheel
         Problem
     3.1. Rolling Wheels
     4. Gears
     4.1. Roller Chain
     4.2. Bike Chain
     5. Swinging Pendulum
     5.1. Newton's Cradle
     5.2: Rock the Rocker
     6. Spiral Pendulum
     7. Coupling Rods
     7.1. Connecting Rods
     8. Psychedelic + Op-Art
     9. Counters + Countdowns
    10. Folding of a Cube
  II. Non-linear Movements
  > 1.0 Speed Up/Slow Down 1
     1.1 Speed Up/Slow Down 2
     2. Fall + Bounce
     3. Acceleration by
          physical Formulas
     4. Speed Controll by
          Spline Functions
  III. Animation Paths
      with Spline Curves
     1. Spline Curves
     2. Closed Splines
     3. Animation Paths
                                                       

Speed Up and Slow Down (1)
Realistic nonlinear movements with useful basic functions.

Realistic simulation of
Acceleration and Retardation

4 useful macros:
//---------------------------
#macro Cos_01( X )
  (0.5-0.5*cos(  pi*X))
#end
//---------------------------
#macro Cos_010( X )
  (0.5-0.5*cos(2*pi*X))
#end
//---------------------------
#macro Cos_10( X )
  (1-(0.5-0.5*cos(  pi*X)))
#end
//---------------------------
#macro Cos_101( X )
  (1-(0.5-0.5*cos( 2*pi*X)))
#end
//---------------------------

speed up and slow down
macro 'Cos_01( TIME )'
Start smooth, end smooth.
speed up and slow down
macro 'Cos_010( TIME )'
Start smooth, return smooth,
come back and end smooth.
speed up and slow down
macro 'Cos_10( TIME )'
Start smooth, end smooth.
speed up and slow down
macro 'Cos_101( TIME )'
Start smooth, return smooth,
come back and end smooth.

Here some example how to use:
#macro Cos_010( X ) //------------
  (0.5-0.5*cos(2*pi*X))
#end //---------------------------
// hard
#object{ Tower // left
  translate<2,0,1+3*clock>}
// smooth
#object{ Tower // right
  translate<3,0,1+3*Cos_01(clock)>}
//--------------------------------
Move smooth
Move hard (left) and smooth (right)
Scene descriptions for POV-Ray:
"Move_hard_n_smooth_1.ini" and
"Move_hard_n_smooth_1.pov"
#macro Cos_010( X ) //-----
  (0.5-0.5*cos(2*pi*X))
#end //--------------------
#declare Fold_Angle =
    -90*Cos_010(clock);
//-------------------------

For complete scene file and more details see: Folding of a Cube.
speed up and slow down
macro 'Cos_101( TIME )'
Start smooth, return smooth,
come back and end smooth.
speed up and slow down
folding without
acceleration
 

Note:
Using exponential functions like f(X)= 1/(1+exp(-X*A+A/2)), with A >=10, meight be a mathematical more correct approximation, but the the problem her: the start and end points are not exact at y=0 resp. y=1!
So f(X)=(0.5-0.5*cos(2*pi*X)) is a better approximation!
Also f(X)= 3*X*X - 2*X*X*X has f(0)= 0, f(1)= 1 and f'(0)=f'(1)=0.
For movements with start and end at v=0 and a=0, a function with 2nd deviation = 0 at start and end, like
f(X)= 6*X5 -15*X4 +10*X3 = X*X*X*(10+X*(6*X-15)) is a more perfect approximation!
speed up and slow down
1/(1+exp(-X*10+10/2))
speed up and slow down
0.5-0.5*cos(2*pi*X)
speed up and slow down
X*X*X*(10+X*(6*X-15))
top

© Friedrich A. Lohmüller, 2012
www.f-lohmueller.de