This page was generated from doc/euclidean/kochanek-bartels-properties.ipynb. Interactive online version: Binder badge.

Properties of Kochanek–Bartels Splines#

Kochanek–Bartels splines are interpolating cubic polynomial splines, with three user-defined parameters per vertex (of course they can also be chosen to be the same three values for the whole spline), which can be used to change the shape and velocity of the spline.

These three parameters are called \(T\) for tension, \(C\) for continuity and \(B\) for bias. With the default values of \(C = 0\) and \(B = 0\), a Kochanek–Bartels spline is identical to a cardinal spline. If the tension parameter also has its default value \(T = 0\), it is also identical to a Catmull–Rom spline.

[1]:
import splines
from helper import plot_spline_2d

Let’s use a bespoke plotting function from kochanek_bartels.py to illustrate the TCB parameters:

[2]:
from kochanek_bartels import plot_tcb

Tension#

[3]:
plot_tcb((0.5, 0, 0), (1, 0, 0), (-0.5, 0, 0), (-1, 0, 0))
../_images/euclidean_kochanek-bartels-properties_6_0.svg

Continuity#

[4]:
plot_tcb((0, -0.5, 0), (0, -1, 0), (0, 0.5, 0), (0, 1, 0))
../_images/euclidean_kochanek-bartels-properties_8_0.svg

Note that the cases \(T = 1\) and \(C = -1\) have a very similar shape (a.k.a. image), but they have a different timing (and therefore different velocities):

[5]:
plot_tcb((1, 0, 0), (0, -1, 0), (0.5, 0, 0), (0, -0.5, 0))
../_images/euclidean_kochanek-bartels-properties_10_0.svg

A value of \(C=-1\) on adjacent vertices leads to linear segments with piecewise constant speeds:

[6]:
vertices1 = [(0, 0), (1, 1), (0, 2), (3, 2), (4, 1), (3, 0)]
s1a = splines.KochanekBartels(vertices1, tcb=(0, -1, 0), endconditions='closed')
plot_spline_2d(s1a, chords=False)
../_images/euclidean_kochanek-bartels-properties_12_0.svg

A value of \(T=1\) will lead to linear segments as well, but the speed will fluctuate in each segment, coming to a complete halt at each control point:

[7]:
s1b = splines.KochanekBartels(vertices1, tcb=(1, 0, 0), endconditions='closed')
plot_spline_2d(s1b, chords=False)
../_images/euclidean_kochanek-bartels-properties_14_0.svg

Bias#

This could also be called overshoot (if \(B > 0\)) and undershoot (if \(B < 0\)):

[8]:
plot_tcb((0, 0, 0.5), (0, 0, 1), (0, 0, -0.5), (0, 0, -1))
../_images/euclidean_kochanek-bartels-properties_17_0.svg

Bias \(-1\) followed by \(+1\) can be used to achieve linear segments between two control points:

[9]:
vertices2 = [(0, 0), (1.5, 0), (1, 1), (0, 0.5)]
tcb2 = [(0, 0, -1), (0, 0, 1), (0, 0, -1), (0, 0, 1)]
s2 = splines.KochanekBartels(vertices2, tcb=tcb2, endconditions='closed')
plot_spline_2d(s2, chords=False)
../_images/euclidean_kochanek-bartels-properties_19_0.svg

A sequence of \(B=-1\), \(C=-1\) and \(B=+1\) can be used to get two adjacent linear segments:

[10]:
vertices3 = [(0, 0), (1, 0), (0, 0.5)]
tcb3 = [(0, 0, -1), (0, -1, 0), (0, 0, 1)]
s3 = splines.KochanekBartels(vertices3, tcb=tcb3, endconditions='closed')
plot_spline_2d(s3, chords=False)
../_images/euclidean_kochanek-bartels-properties_21_0.svg

Combinations#

Of course, multiple parameters can be combined:

[11]:
plot_tcb((1, -1, 0), (-1, 1, 0), (-1, -1, 0), (1, 1, 0))
../_images/euclidean_kochanek-bartels-properties_23_0.svg
[12]:
plot_tcb((1, 0, 1), (-1, 0, 1), (0, -1, 1), (0, 1, -1))
../_images/euclidean_kochanek-bartels-properties_24_0.svg