[][src]Function cubic_spline::calc_spline

pub fn calc_spline(points: &Points, opts: &SplineOpts) -> Result<Points>

The main function that does all the work.

Returns points of curve constructed within the range of passed points using cubic spline interpolation.

Example

use cubic_spline::{Points, TryFrom, SplineOpts};

let src_points = vec![(1.0, 1.0), (3.3, 2.7), (5.1, 0.9)];
let prepared_points = Points::try_from(&src_points).expect("cant convert points");

let options = SplineOpts::new()
  .tension(0.5)
  .num_of_segments(16);

let calculated_points = prepared_points
  .calc_spline(&options)
  .expect("cant construct spline points");

assert_eq!(calculated_points.get_ref().len(), 33);