Trait flo_curves::bezier::BezierCurve
source · pub trait BezierCurve: Geo + Clone + Sized {
Show 13 methods
// Required methods
fn start_point(&self) -> Self::Point;
fn end_point(&self) -> Self::Point;
fn control_points(&self) -> (Self::Point, Self::Point);
// Provided methods
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) -> f64 { ... }
fn section(&self, t_min: f64, t_max: f64) -> CurveSection<'_, Self> { ... }
}
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)
To find the nearest points on the curve where the point is far away, consider using nearest_t()
, and
nearest_point()
instead. For interactive applications, ray casting with curve_intersects_ray()
might
be better used to find which area of a curve a user might be trying to indicate.
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) -> f64
fn estimate_length(&self) -> f64
Attempts to estimate the length of this curve
sourcefn section(&self, t_min: f64, t_max: f64) -> CurveSection<'_, Self>
fn section(&self, t_min: f64, t_max: f64) -> CurveSection<'_, Self>
Create a section from this curve. Consider calling subsection
for curves
that are already CurveSections
.