splines§
Piecewise polynomial curves (in Euclidean space).
Submodules
Quaternions and unitquaternion splines. 
Classes

Piecewise Bézier curve using Bernstein basis. 

CatmullRom spline. 

Reparameterize a spline to have constant speed. 

Cubic Hermite curve. 

KochanekBartels spline. 

Piecewise polynomial curve using monomial basis. 

Monotone cubic curve. 

Natural spline. 

Reparameterize a spline with new grid values. 

Piecewise monotone cubic curve. 
 class splines.Monomial(segments, grid)[source]§
Bases:
object
Piecewise polynomial curve using monomial basis.
See Polynomial Parametric Curves.
Coefficients can have arbitrary dimension. An arbitrary polynomial degree \(d\) can be used by specifying \(d + 1\) coefficients per segment. The \(i\)th segment is evaluated using this equation:
\[\boldsymbol{p}_i(t) = \sum_{k=0}^d \boldsymbol{a}_{i,k} \left(\frac{t  t_i}{t_{i+1}  t_i}\right)^k \text{ for } t_i \leq t < t_{i+1}\]This is similar to
scipy.interpolate.PPoly
, which states:“Highorder polynomials in the power basis can be numerically unstable. Precision problems can start to appear for orders larger than 2030.”
This shouldn’t be a problem since most commonly splines of degree 3 (i.e. cubic splines) are used.
 Parameters
segments – Sequence of polynomial segments. Each segment \(\boldsymbol{a}_i\) contains coefficients for the monomial basis (in order of decreasing degree). Different segments can have different polynomial degree.
grid – Sequence of parameter values \(t_i\) corresponding to segment boundaries. Must be strictly increasing.
 class splines.Bernstein(segments, grid=None)[source]§
Bases:
object
Piecewise Bézier curve using Bernstein basis.
See Bézier Splines.
 Parameters
segments – Sequence of segments, each one consisting of multiple Bézier control points. Different segments can have different numbers of control points (and therefore different polynomial degrees).
grid (optional) – Sequence of parameter values corresponding to segment boundaries. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
 static basis(degree, t)[source]§
Bernstein basis polynomials of given degree, evaluated at t.
Returns a list of values corresponding to \(i = 0, \ldots, n\), given the degree \(n\), using the formula
\[b_{i,n}(t) = {n \choose i} t^i \left( 1  t \right)^{n  i},\]with the binomial coefficient \({n \choose i} = \frac{n!}{i!(n  i)!}\).
 class splines.CubicHermite(vertices, tangents, grid=None)[source]§
Bases:
splines.Monomial
Cubic Hermite curve.
See Hermite Splines.
 Parameters
vertices – Sequence of vertices.
tangents – Sequence of tangent vectors (two per segment, outgoing and incoming).
grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
 matrix = array([[ 2, 2, 1, 1], [3, 3, 2, 1], [ 0, 0, 1, 0], [ 1, 0, 0, 0]])§
 class splines.CatmullRom(vertices, grid=None, *, alpha=None, endconditions='natural')[source]§
Bases:
splines.CubicHermite
Catmull–Rom spline.
This class implements one specific member of the family of splines described in [CR74], which is commonly known as Catmull–Rom spline: The cubic spline that can be constructed by linear Lagrange interpolation (and extrapolation) followed by quadratic Bspline blending, or equivalently, quadratic Lagrange interpolation followed by linear Bspline blending.
The implementation used in this class, however, does nothing of that sort. It simply calculates the appropriate tangent vectors at the control points and instantiates a
CubicHermite
spline.See CatmullRom Splines.
 Parameters
vertices – Sequence of vertices.
grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
alpha (optional) – TODO
endconditions (optional) – Start/end conditions. Can be
'closed'
,'natural'
or pair of tangent vectors (a.k.a. “clamped”). If'closed'
, the first vertex is reused as last vertex and an additional grid time has to be specified.
 class splines.KochanekBartels(vertices, grid=None, *, tcb=(0, 0, 0), alpha=None, endconditions='natural')[source]§
Bases:
splines.CubicHermite
Kochanek–Bartels spline.
See KochanekBartels Splines.
 Parameters
vertices – Sequence of vertices.
grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
tcb (optional) – Sequence of tension, continuity and bias triples. TCB values can only be given for the interior vertices.
alpha (optional) – TODO
endconditions (optional) – Start/end conditions. Can be
'closed'
,'natural'
or pair of tangent vectors (a.k.a. “clamped”). If'closed'
, the first vertex is reused as last vertex and an additional grid time has to be specified.
 class splines.Natural(vertices, grid=None, *, alpha=None, endconditions='natural')[source]§
Bases:
splines.CubicHermite
Natural spline.
See Natural Splines.
 Parameters
vertices – Sequence of vertices.
grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
alpha (optional) – TODO
endconditions (optional) – Start/end conditions. Can be
'closed'
,'natural'
or pair of tangent vectors (a.k.a. “clamped”). If'closed'
, the first vertex is reused as last vertex and an additional grid time has to be specified.
 class splines.PiecewiseMonotoneCubic(values, grid=None, slopes=None, *, alpha=None, closed=False)[source]§
Bases:
splines.CatmullRom
Piecewise monotone cubic curve.
See Piecewise Monotone Interpolation.
This only works for onedimensional values.
For undefined slopes,
_calculate_tangent()
is called on the base class. Parameters
values – Sequence of values to be interpolated.
grid (optional) – Sequence of parameter values. Must be strictly increasing. If not specified, a uniform grid is used (0, 1, 2, 3, …).
slopes (optional) – Sequence of slopes or
None
if slope should be computed from neighboring values. An error is raised if a segment would become nonmonotone with a given slope.
 class splines.MonotoneCubic(values, *args, **kwargs)[source]§
Bases:
splines.PiecewiseMonotoneCubic
Monotone cubic curve.
This takes the same arguments as
PiecewiseMonotoneCubic
(exceptclosed
), but it raises an error if the given values are not montone.
 class splines.ConstantSpeedAdapter(curve)[source]§
Bases:
object
Reparameterize a spline to have constant speed.
For splines in Euclidean space this amounts to arclength parameterization.
However, this class is implemented in a way that also allows using rotation splines which will be reparameterized to have constant angular speed.
The parameter s represents the cumulative arclength or the cumulative rotation angle, respectively.
 class splines.NewGridAdapter(curve, new_grid=1)[source]§
Bases:
object
Reparameterize a spline with new grid values.
 Parameters
curve – A spline.
new_grid (optional) – If a single number is given, the new parameter will range from 0 to that number. Otherwise, a sequence of numbers has to be given, one for each grid value. Instead of a value,
None
can be specified to choose a value automatically. The first and last value cannot beNone
.