Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
logo
    3D Animations with POV-Ray
        Some basics and samples 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 Sample
     2. From Images to Video
     3. Basic Terms
     4. Animation Commands
  I. Cyclic Animations
     1. Rotating Objects
     1.2. Planets in Orbit
     1.3. Clock Animation
     2. Rotating 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
     6. Spiral Pendulum
     7. Connecting Rods
     8. Psychedelic
        + Op-Art
     9. Counters
        + Countdowns
    10. Folding of a Cube
  II. Animation Paths
      with Spline Curves
     1. Spline Curves
     2. Animation Paths
                                           

The Concept of the Spline Curves

The harmonic connection of a row of points.
           

The Spline Function "spline{ ... }":
A spline function is a relation between given time values and according vectors of positions (anchor points). POV-Ray calculates with this function all values between these given points for a curve which connects these anchor points.

#declare Spline_1 =
  spline {
   natural_spline
  -0.2, <-2,1.0,-2>,//control point

   0.0, <-0,1.0,-2>,//start point
   0.2, < 2,1.0,-2>,
   0.4, < 2,1.0, 0>,
   0.6, < 0,1.0, 0>,
   0.8, < 0,1.0, 2>,
   1.0, < 2,1.0, 2>,//end point

   1.2, < 4,1.0, 2>//control point
  }

spline demo

Spline Demo
complete scene description for POV-Ray:
"spline_demo.pov"

In POV-Ray there are 4 different types of splines:
linear_spline   = Straight lines are connecting the anchor points (This is default).
quadratic_spline = Connecting the anchor points by a smooth curve of 2nd order.
cubic_spline   = Connecting the anchor points by a more smooth curve of 3rd order.
natural_spline = Connecting the anchor points by a very smooth curve of 3rd order

For animation paths without jerky motions it's optimal to use the spline types cubic_spline and natural_spline. Using cubic_spline and natural_spline we have to define additional control points before and behind our anchor points to control the bending of the curve in our start and end points.
In the image above "Spline Demo" the anchor points are yellow and the control points are red. With a While loop the spline curve is marked with little spheres:


 #declare Nr = 0;     // start
 #declare EndNr = 1;  // end
 #while (Nr< EndNr)   // -----------------------------------
 sphere{ <0,0,0>,0.07
          texture{ pigment{color rgb <1-Nr/2,0.75+Nr/4,0>}
                  finish {diffuse 0.9 phong 1}
                }
         translate Spline_1(Nr)
       } // end of sphere

 #declare Nr = Nr + 0.005;  // next Nr
 #end // -------------------------------------- end of loop


Animation paths with spline curves: As a camera path or as a flight path of animated objects we i.e. can use a closed spline curve.

#declare P1 = <-2.00, 0.20, -2.00>;
#declare P2 = < 1.00, 0.20, -2.00>;
#declare P3 = < 2.00, 0.70, -1.00>;
#declare P4 = < 2.00, 1.20,  2.00>;
#declare P5 = < 0.00, 0.20,  2.00>;
#declare P6 = <-2.00, 3.20,  1.50>;
#declare P7 = <-2.00, 0.70, -1.00>;
#declare P8 = <-2.00, 0.00, -2.00>;

#declare Spline_1 =
  spline {
    natural_spline
   -0.250, P7, // control point
    0.000, P1, // starting point
    0.125, P2,
    0.250, P3,
    0.420, P4,
    0.490, P5,
    0.780, P6,
    0.900, P7,
    1.000, P1, // end point
    1.125, P2  // control point
  }// end of spline ---------------

closed spline curve
complete scene description for POV-Ray:
"spline00.pov"

Closed Spline Curves:
We'll get a perfectly closed spline curve under the following conditions:
The end point is the same as the starting point.
The control point before the beginning is the point before the end point.
The control point at the end is the point behind the starting point.
The distances of the time values at the control point must also fit to those of their according points.

top

© Friedrich A. Lohmüller, 2008
email email: Friedrich.Lohmueller_at_t-online.de
homepage:http://www.f-lohmueller.de