cubic_spline
Interpolation methods for computation of cubic spline points within the range of a discrete set of known points.
Example
use ;
let points = vec!;
let opts = SplineOpts ;
let pts: = new;
let mut result = new;
pts.calc;
assert_eq!;
//
// Same as:
//
use ;
let spline_points = from_tuples;
assert_eq!;
For now source and resulting points may be Vec<f64> - (vec![x,y,x,y,...]) or Vec<(f64, f64)> - (vec![(x,y),(x,y), ...]).
For this types of points there are two helper functions Spline::from_flatten_points and Spline::from_tuples
Custom points
If you allready have some points to avoid unnecessary copying, creating new Vec etc. you can implement GetPoint trait. And if you need some particular result implement PushPoint.
Example
use ;
;
;
let points: = vec!;
let pts = MySrcPoint;
let mut result = MyResult;
pts.calc;
See here for implementation example
Example for js
import from 'cubic-spline-rs'
const NUM_OF_SEGMENTS = 22
const points =
const curvePoints =
Options
| Name | Type | Default | Description |
|---|---|---|---|
| tension | f64 |
0.5 |
Tension |
| num_of_segments | u32 |
16 |
Number of calculated points between known points |
| disallow_x_stepping_back | bool |
false |
If true checks that every x value of point is greater than previous |
use ;
let opts = SplineOpts
Enjoy using!
License
This module is MIT licensed.