Trait flo_curves::BezierCurve
source · pub trait BezierCurve: Geo + Clone + Sized {
fn start_point(&self) -> Self::Point;
fn end_point(&self) -> Self::Point;
fn control_points(&self) -> (Self::Point, Self::Point);
fn reverse<Curve: BezierCurveFactory<Point = Self::Point>>(self) -> Curve { ... }
fn point_at_pos(&self, t: f64) -> Self::Point { ... }
fn t_for_point(&self, point: &Self::Point) -> Option<f64> { ... }
fn subdivide<Curve: BezierCurveFactory<Point = Self::Point>>(
&self,
t: f64
) -> (Curve, Curve) { ... }
fn bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds { ... }
fn fast_bounding_box<Bounds: BoundingBox<Point = Self::Point>>(
&self
) -> Bounds { ... }
fn search_with_bounds<MatchFn: Fn(Self::Point, Self::Point) -> bool>(
&self,
max_error: f64,
match_fn: MatchFn
) -> Vec<f64> { ... }
fn find_extremities(&self) -> Vec<f64> { ... }
fn estimate_length(&self, max_t: f64) -> f64 { ... }
}
Expand description
Trait implemented by things representing a cubic bezier curve
Required Methods
sourcefn start_point(&self) -> Self::Point
fn start_point(&self) -> Self::Point
The start point of this curve
sourcefn control_points(&self) -> (Self::Point, Self::Point)
fn control_points(&self) -> (Self::Point, Self::Point)
The control points in this curve
Provided Methods
sourcefn reverse<Curve: BezierCurveFactory<Point = Self::Point>>(self) -> Curve
fn reverse<Curve: BezierCurveFactory<Point = Self::Point>>(self) -> Curve
Reverses the direction of this curve
sourcefn point_at_pos(&self, t: f64) -> Self::Point
fn point_at_pos(&self, t: f64) -> Self::Point
Given a value t from 0 to 1, returns a point on this curve
sourcefn t_for_point(&self, point: &Self::Point) -> Option<f64>
fn t_for_point(&self, point: &Self::Point) -> Option<f64>
Given a point that is on or very close to the curve, returns the t value where the point can be found (or None if the point is not very close to the curve)
sourcefn subdivide<Curve: BezierCurveFactory<Point = Self::Point>>(
&self,
t: f64
) -> (Curve, Curve)
fn subdivide<Curve: BezierCurveFactory<Point = Self::Point>>(
&self,
t: f64
) -> (Curve, Curve)
Given a value t from 0 to 1, finds a point on this curve and subdivides it, returning the two resulting curves
sourcefn bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds
fn bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds
Computes the bounds of this bezier curve
sourcefn fast_bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds
fn fast_bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds
Faster but less accurate bounding box for a curve
This will produce a bounding box that contains the curve but which may be larger than necessary
sourcefn search_with_bounds<MatchFn: Fn(Self::Point, Self::Point) -> bool>(
&self,
max_error: f64,
match_fn: MatchFn
) -> Vec<f64>
fn search_with_bounds<MatchFn: Fn(Self::Point, Self::Point) -> bool>(
&self,
max_error: f64,
match_fn: MatchFn
) -> Vec<f64>
Given a function that determines if a searched-for point is within a bounding box, searches the curve for the t values for the corresponding points
sourcefn find_extremities(&self) -> Vec<f64>
fn find_extremities(&self) -> Vec<f64>
Finds the t values where this curve has extremities
sourcefn estimate_length(&self, max_t: f64) -> f64
fn estimate_length(&self, max_t: f64) -> f64
Attempts to estimate the length of this curve