HowTo:Use Splines and Bezier Curves

From POV-Wiki
Jump to navigation Jump to search

Introduction

All Curves and Patches utilised by POVRay are influenced by a number of control points. All curves pass through the start and the end control point, while most of the curves pass through the intermediate control points.

Splines

Splines may be of Linear, Quadratic or Cubic type of Spline and are accessed with the command #spline as shown below.

#declare MYSPLINE = spline {
    cubic_spline
    -1,  <-1,0,0>
     0,  <2,-1,0>
     1,  <3,-1,2>
     2,  <5,0,5>
     3,  <3,3,3>
     4,  <2,2,2>
     5,  <2,-1,0>
     6,  <3,-1,2>
     7,  <5,0,5>
}

#declare count = 0;
#while (count <= 5)
  #sphere {  MYSPLINE (count), 0.25 pigment {Blue} }
  #declare count = count + 0.01;
#end

All "spline" type splines pass through the intermediate control points, these are:

  1. A linear spline will move linearly from one control point to the next.
  2. A Quadratic Spline will pass from one point to the next with reference only to where it is going.
  3. A Cubic Spline will pass from one control point to the next with reference to where it cam from and where it will go to next.

The important thing to remember about using splines is that as the control number exceeds a control point, the next increment of control points is taken to control the path of the spline. Sufficient control points need to be defined otherwise POVRay will yield an error or misrepresent the scene.

Bezier Curves

About Bicubic Patches