Trait rasterize::Curve

source ·
pub trait Curve: Into<Segment> {
Show 17 methods // Required methods fn flatness(&self) -> Scalar; fn transform(&self, tr: Transform) -> Self; fn start(&self) -> Point; fn end(&self) -> Point; fn at(&self, t: Scalar) -> Point; fn split_at(&self, t: Scalar) -> (Self, Self); fn cut(&self, a: Scalar, b: Scalar) -> Self; fn bbox(&self, init: Option<BBox>) -> BBox; fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>); fn deriv(&self) -> Segment; fn reverse(&self) -> Self; fn roots(&self) -> CurveRoots; fn extremities(&self) -> CurveExtremities; fn length(&self, t0: Scalar, t1: Scalar) -> Scalar; // Provided methods fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter { ... } fn split(&self) -> (Self, Self) { ... } fn param_at_length(&self, l: Scalar, error: Option<Scalar>) -> Scalar { ... }
}
Expand description

Set of operations common to all bezier curves.

Required Methods§

source

fn flatness(&self) -> Scalar

Correspond to maximum deviation of the curve from the straight line f = max |curve(t) - line(curve_start, curve_end)(t)|. This function actually returns 16.0 * f^2 to avoid unneeded division and square root.

source

fn transform(&self, tr: Transform) -> Self

Apply affine transformation to the curve

source

fn start(&self) -> Point

Point at which curve starts

source

fn end(&self) -> Point

Point at which curve ends

source

fn at(&self, t: Scalar) -> Point

Evaluate curve at parameter value t in (0.0..=1.0)

source

fn split_at(&self, t: Scalar) -> (Self, Self)

Split the curve at parameter value t

source

fn cut(&self, a: Scalar, b: Scalar) -> Self

Create sub-curve specified starting at parameter value a and ending at value b

source

fn bbox(&self, init: Option<BBox>) -> BBox

Extend provided init bounding box with the bounding box of the curve

source

fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)

Offset the curve by distance dist, result is inserted into out container

source

fn deriv(&self) -> Segment

Derivative with respect to t, deriv(t) = [curve'(t)_x, curve'(t)_y]

source

fn reverse(&self) -> Self

Identical curve but directed from end to start, instead of start to end.

source

fn roots(&self) -> CurveRoots

Find roots of the equation curve(t)_y = 0. Values of the parameter at which curve crosses y axis.

source

fn extremities(&self) -> CurveExtremities

Find all extremities of the curve curve'(t)_x = 0 || curve'(t)_y = 0

source

fn length(&self, t0: Scalar, t1: Scalar) -> Scalar

Calculate length of the curve from t0 to t1

Provided Methods§

source

fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter

Convert curve to an iterator over line segments with desired flatness

source

fn split(&self) -> (Self, Self)

Optimized version of Curve::split_at(0.5)

source

fn param_at_length(&self, l: Scalar, error: Option<Scalar>) -> Scalar

Find value of parameter t given desired l length of the segment

This method is not particularly fast, parameter value is found by solving f(t) = self.length(0.0, t) - l == 0 using Newton’s method with fallback to bisection if next iteration will produce out of bound value.

Reference: https://www.geometrictools.com/Documentation/MovingAlongCurveSpecifiedSpeed.pdf

Object Safety§

This trait is not object safe.

Implementors§