splinebox.basis_functions.CubicHermite.

filter_symmetric#

static CubicHermite.filter_symmetric(s)#

Returns a filtered version of the input s, used to convert knots into control points for an open spline.

Parameters:
snumpy.array

An array of knots of shape (n, dim) where n is the number of knots and dim is the dimensionality of the codomain, i.e. the space in which the curve lives. Note that the knots should be padded.

Returns:
control_pointsnumpy.array

The control points for the spline passing through the knots provided.

Examples

For interpolating basis functions the filter is the identity.

>>> knots = np.array([[4, 3], [2, 2], [1, 3]])
>>> b1 = splinebox.basis_functions.B1()
>>> b1.filter_symmetric(knots)
array([[4., 3.],
       [2., 2.],
       [1., 3.]])

For non-interpolating spline the returned control points are different.

>>> b3 = splinebox.basis_functions.B3()
>>> b3.filter_symmetric(knots)
array([[5.25, 4.  ],
       [1.5 , 1.  ],
       [0.75, 4.  ]])

We can confirm that the returned control points indeed results in the second knot provided.

>>> control_points = b3.filter_symmetric(knots)
>>> b3(-1) * control_points[0] + b3(0) * control_points[1] + b3(1) * control_points[2]
array([2., 2.])

To perform the same test for the first and the last knot, padding is required.