cubic_spline

Crates.io

Interpolation methods for computation of cubic spline points within the range of a discrete set of known points.

Online documentation
Demo

Example for flatten vec

```rust use cubic_spline::{Spline, SplineOpts};

let opts: SplineOpts = Default::default();

let points = vec![10.0, 200.0, 256.0, 390.0, 512.0, 10.0, 778.0, 200.0];

let splinepoints = Spline::fromflatten_points(&points, &opts);

asserteq!(splinepoints.len(), 102); ```

Example for tuples vec

```rust use cubic_spline::{Spline, SplineOpts};

let opts: SplineOpts = Default::default();

let points = vec![(10.0, 200.0), (256.0, 390.0), (512.0, 10.0), (778.0, 200.0)];

let splinepoints = Spline::fromtuples(&points, &opts);

let (lastx, lasty) = splinepoints.last().unwrap(); asserteq!(last_y, 200.0); ```

Options

| Name | Type | Default | Description | |--------------------------|:------:|:-------:|-----------------------------------------------------------------------| | tension | f64 | 0.5 | Tension | | numofsegments | u32 | 16 | Number of calculated points between known points | | disallowxstepping_back | bool | false | If true checks that every x value of point is greater than previous |

rust use cubic_spline::{SplineOpts}; let opts = SplineOpts { tension: 0.6, ..Default.default() }

Enjoy using!

License

This module is MIT licensed.