pub fn cubic_spline_interpolate<T>(
    input: f32,
    inputs: &[f32],
    outputs: &[T],
    normalize: bool
) -> Twhere
    T: InterpolationPrimitive + Clone,
Expand description

Cubic Hermite spline interpolation

f(t) = (2d^3 + 3d^2 + 1)p0 + (d^3 - 2d^2 + d)m0 + (-2d^3 + 3d^2)p1 + (d^3 - d^2)m1 d = (t - t0) / (t1 - t0) p0 = position at left keyframe p1 = position at right keyframe m0 = out tangent at left keyframe * (t1 - t0) m1 = in tangent at right keyframe * (t1 - t0) t0 = input at left keyframe t1 = input at right keyframe

Parameters:

  • input: the input value to the function
  • inputs: list of discrete input values for each keyframe
  • outputs: list of output values to interpolate between, for cubic spline interpolation this should three times the size of inputs and defined as [ in_tangent_0, position_0, out_tangent_0, in_tangent_1, position_1, out_tangent_1, .. ]
  • normalize: if true, normalize the interpolated value before returning it