Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.45 KB

README.md

File metadata and controls

42 lines (31 loc) · 1.45 KB

Curve Package Documentation Build

The package provides curves.

Examples

Trace a Bézier curve:

use curve::bezier::Linear;
use curve::Trace;

let curve = (Linear::new(1.0, 5.0), Linear::new(2.0, 3.0));
let points = Trace::new(curve, 3).collect::<Vec<_>>();
assert_eq!(points, vec![(1.0, 2.0), (3.0, 2.5), (5.0, 3.0)]);

Approximate a cubic Bézier curve with a sequence of quadratic:

use curve::bezier::goodness::CrudeIndependentAbsolute;
use curve::bezier::Cubic;
use curve::Approximation;

let goodness = CrudeIndependentAbsolute::new(1.0, f64::MAX, usize::MAX);
let cubic = (Cubic::new(0.0, 0.0, 90.0, 100.0), Cubic::new(0.0, 50.0, 0.0, 0.0));
let quadratics = Approximation::new(cubic, goodness).collect::<Vec<_>>();
assert_eq!(quadratics.len(), 4);

Contribution

Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.