Skip to content

Commit

Permalink
Add a couple of extra examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Logicalshift committed Feb 27, 2023
1 parent d070106 commit 8f5ceb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/bezier/fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const MAX_POINTS_TO_FIT: usize = 100;
/// * We only try to fit a certain number of points at once as the algorithm runs
/// in quadratic time otherwise
///
pub fn fit_curve<Curve: BezierCurveFactory+BezierCurve>(points: &[Curve::Point], max_error: f64) -> Option<Vec<Curve>> {
pub fn fit_curve<Curve>(points: &[Curve::Point], max_error: f64) -> Option<Vec<Curve>>
where
Curve: BezierCurveFactory + BezierCurve
{
// Need at least 2 points to fit anything
if points.len() < 2 {
// Insufficient points for this curve
Expand Down
4 changes: 3 additions & 1 deletion src/bezier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
//! #
//! let curve = Curve::from_points(Coord2(1.0, 2.0), (Coord2(2.0, 0.0), Coord2(3.0, 5.0)), Coord2(4.0, 2.0));
//! let mid_point = curve.point_at_pos(0.5);
//! let all_points = walk_curve_evenly(&curve, 1.0, 0.01).collect::<Vec<_>>();
//! let all_points = walk_curve_evenly(&curve, 1.0, 0.01).map(|section| section.point_at_pos(0.5)).collect::<Vec<_>>();
//! let fitted_curve = fit_curve::<Curve<Coord2>>(&all_points, 0.1);
//! let intersections = curve_intersects_ray(&curve, &(Coord2(1.0, 1.0), Coord2(2.0, 2.0)));
//! let offset_curve = offset(&curve, 2.0, 2.0);
//! ```
//!
//! Anything that implements the `BezierCurve` trait can be manipulated by the functions in this crate. The `Curve` type
Expand Down

0 comments on commit 8f5ceb1

Please sign in to comment.