splinebox.basis_functions.B2.

filter_periodic#

B2.filter_periodic(s)#

Returns a filtered version of the input s, used to convert knots into control points for a closed 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 is the identity.

>>> knots = np.array([[4, 3], [2, 2], [1, 3]])
>>> b1 = splinebox.basis_functions.B1()
>>> b1.filter_periodic(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_periodic(knots)
array([[ 5.667,  3.333],
       [ 1.667,  1.333],
       [-0.333,  3.333]])

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

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

For the other two knots we need to take the preiodicity into account.

>>> b3(-1) * control_points[-1] + b3(0) * control_points[0] + b3(1) * control_points[1]
array([4., 3.])
>>> b3(-1) * control_points[1] + b3(0) * control_points[2] + b3(1) * control_points[0]
array([1., 3.])