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§

source

fn start_point(&self) -> Self::Point

The start point of this curve

source

fn end_point(&self) -> Self::Point

The end point of this curve

source

fn control_points(&self) -> (Self::Point, Self::Point)

The control points in this curve

Provided Methods§

source

fn reverse<Curve: BezierCurveFactory<Point = Self::Point>>(self) -> Curve

Reverses the direction of this curve

source

fn point_at_pos(&self, t: f64) -> Self::Point

Given a value t from 0 to 1, returns a point on this curve

source

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.

source

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

source

fn bounding_box<Bounds: BoundingBox<Point = Self::Point>>(&self) -> Bounds

Computes the bounds of this bezier curve

source

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

source

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

source

fn find_extremities(&self) -> Vec<f64>

Finds the t values where this curve has extremities

source

fn estimate_length(&self) -> f64

Attempts to estimate the length of this curve

source

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.

Implementors§

source§

impl<'a, C: 'a + BezierCurve> BezierCurve for CurveSection<'a, C>

source§

impl<'a, Point: 'a + Coordinate, Label: 'a + Copy> BezierCurve for GraphEdge<'a, Point, Label>

source§

impl<Coord: Coordinate> BezierCurve for Curve<Coord>