bosing.Interp

class bosing.Interp(knots, controls, degree)

基类:Shape

An interpolated shape.

The interpolated shape use a B-spline. scipy.interpolate.make_interp_spline() can be used to calculate the parameters.

小心

It's user's responsibility to ensure the b-spline parameters are valid and the shape is normalized such that \(f(\pm 0.5) = 0\) and \(f(0) = 1\).

参数:
  • knots (Sequence[float]) -- Knots of the B-spline.

  • controls (Sequence[float]) -- Control points of the B-spline.

  • degree (int) -- Degree of the B-spline.

示例

import numpy as np
from scipy.interpolate import make_interp_spline
from bosing import Interp
x = np.linspace(0, np.pi, 10)
y = np.sin(x)
x = (x - x[0]) / (x[-1] - x[0]) - 0.5 # Normalize x to [-0.5, 0.5]
spline = make_interp_spline(x, y, k=3)
interp = Interp(spline.t, spline.c, spline.k)
controls
degree
knots