pub fn spline<B, T, U>(x: T, knots: &[U]) -> Uwhere
    B: Basis<T>,
    T: AsPrimitive<usize> + Float + FromPrimitive + PartialOrd + One + Zero,
    U: Add<Output = U> + Copy + Mul<T, Output = U> + Zero,
Expand description

As x varies from 0 to 1, this function returns the value of a cubic interpolation of uniformly spaced knots. The input value x will be clamped to the range [0, 1].

Depending on the choosen Basis the length of the knots parameter has certain constraints.

If these constraints are not honored the code produces undefined behavior in a release build.

Panics

If the knots slice has the wrong length this will panic when the code is built with debug assertion enabled.

Use the is_len_ok() helper to check if a knot slice you want to feed to this function has the correct length.

Examples

use uniform_cubic_splines::{basis::CatmullRom, spline};

//                 0.0  0.25 0.5  0.75 1.0
let knots = [-0.4, 0.0, 0.4, 0.5, 0.9, 1.0, 1.9];

assert_eq!(0.4, spline::<CatmullRom, _, _>(0.25f64, &knots));