User:Le Forgeron/splines

From POV-Wiki
Jump to navigation Jump to search

Splines

LeForgeronSpline03.png

LeForgeronSpline09.png

LeForgeronSpline10.png

LeForgeronSpline11.png

Accessing splines data

Not only the value of a spline can be evaluated with the traditional SPLINE_IDENTIFIER ( FLOAT [, SPLINE_TYPE] ), it is also possible to get back the actual pieces of information from a spline.

dimension_size( SPLINE_IDENTIFIER ) provides the number of entries in the spline.

For each entry, the spline can be accessed like an array, the first element is the float of the path list and the second element the associated vector.

  • SPLINE_IDENTIFIER[ INDEX ][0] is a float
  • SPLINE_IDENTIFIER[ INDEX ][1] is a vector
  • INDEX should evolve as an integer from 0 to dimension_size(SPLINE_IDENTIFIER)-1

Additional types of splines

Sor spline

LeForgeronSpline12.png

the curve followed by a sor can be evaluted by a spline of sor_spline type with a bit of manipulation: the y value of the sor must be used as the float of the path, and the x value become one of the component of the vector. The component of the vector never get negative with a sor spline.

spline{
   sor_spline
  -1.000000,0.000000*x
   0.000000,0.118143*x
   0.540084,0.620253*x
   0.827004,0.210970*x
   0.962025,0.194093*x
   1.000000,0.286920*x
   1.033755,0.468354*x
}

sor{
  7
  <0.000000, -1.000000>
  <0.118143,  0.000000>
  <0.620253,  0.540084>
  <0.210970,  0.827004>
  <0.194093,  0.962025>
  <0.286920,  1.000000>
  <0.468354,  1.033755>
}

akima spline

LeForgeronSpline00.png

That spline will go through all its points, smoothly.

spline {
  akima_spline
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
    ...
  time_Val_n, <Vector_n>
}

tcb spline

LeForgeronSpline13.png

LeForgeronSpline14.png

LeForgeronSpline15.png

LeForgeronSpline16.png

LeForgeronSpline17.png

Also know as Kochanek-Bartels spline, tcb stand for tension, continuity and bias.

The first and last point of such spline are not reached.

spline {
  tcb_spline [TCB_PARAMETERS]
  time_Val_1 [TCB_PARAMETERS], <Vector_1> [TCB_PARAMETERS][,]
  time_Val_2 [TCB_PARAMETERS], <Vector_2> [TCB_PARAMETERS][,]
    ...
  time_Val_n [TCB_PARAMETERS], <Vector_n> [TCB_PARAMETERS]
}

TCB_PARAMETERS:
  [tension FLOAT] [continuity FLOAT] [bias FLOAT]

The tension, continuity and bias are fully optional. Depending on the place where they appear, they control the spline in different ways:

  • Placed right after the tcb_spline keyword, they set the default values for all ends of the spline segments. This placement is ignored in case of copying spline without adding new controls because previous defaults were already propagated to each side of control points.
  • Placed between the time_value and the corresponding vector, the tcb parameters determine the properties of the spline segment ending in the vector that follows these parameters (as well as for the spline segment beginning at this vector if not overriden with the third position).
  • For tcb parameters following a vector, the properties of the spline segment beginning after this vector are set.

What is controlled by these parameters?

  • tension controls how sharply the curve bends.
  • continuity controls how rapid speed and direction change.
  • bias controls the direction of the curve as it passes through the control point.

x splines

X-Splines are an alternative to traditional splines that was introduced by Carole Blanc and Christophe Schlick in 1995.

XSplines have the very nice property that they can interpolate (go through) a control point as well as just approximate it. Sharp edges are also possible, but the curve is always C2 continuous, hence the sharp edges are only possible when the first derivative drops to zero.

An X-Spline is completely defined by a set of control point (vertices) and a set of parameters. One parameter is associated with each control point.

There is 3 variations of x splines:

  • basic
  • extended
  • general
basic x spline

The first and last point of such spline are not reached.

LeForgeronSpline01.png

LeForgeronSpline02.png

spline {
  basic_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [,]
  time_Val_2, <Vector_2> [,]
  ...
  time_Val_n, <Vector_n>
}

The freedom_degree before the first point is the value for all points (0.0 by default)

extended x spline

LeForgeronSpline04.png

LeForgeronSpline05.png

Extended spline are always C², but allows sharp points (where both the first and second derivatives drop to zero). All the points are visited.

spline {
  extended_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [freedom_degree FLOAT] [,]
  time_Val_2, <Vector_2> [freedom_degree FLOAT] [,]
  ...
  time_Val_n, <Vector_n> [freedom_degree FLOAT]
}

The freedom_degree before the first point is the default value (0.0 by default)

general x spline

LeForgeronSpline06.png

LeForgeronSpline07.png

LeForgeronSpline08.png

All points are visited.

spline {
  general_x_spline [freedom_degree FLOAT]
  time_Val_1, <Vector_1> [freedom_degree FLOAT] [,]
  time_Val_2, <Vector_2> [freedom_degree FLOAT] [,]
  ...
  time_Val_n, <Vector_n> [freedom_degree FLOAT]
}

The freedom_degree before the first point is the default value (0.0 by default)