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§
sourcefn flatness(&self) -> Scalar
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.
sourcefn split_at(&self, t: Scalar) -> (Self, Self)
fn split_at(&self, t: Scalar) -> (Self, Self)
Split the curve at parameter value t
sourcefn cut(&self, a: Scalar, b: Scalar) -> Self
fn cut(&self, a: Scalar, b: Scalar) -> Self
Create sub-curve specified starting at parameter value a
and ending at value b
sourcefn bbox(&self, init: Option<BBox>) -> BBox
fn bbox(&self, init: Option<BBox>) -> BBox
Extend provided init
bounding box with the bounding box of the curve
sourcefn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
Offset the curve by distance dist
, result is inserted into out
container
sourcefn reverse(&self) -> Self
fn reverse(&self) -> Self
Identical curve but directed from end to start, instead of start to end.
sourcefn roots(&self) -> CurveRoots
fn roots(&self) -> CurveRoots
Find roots of the equation curve(t)_y = 0
. Values of the parameter at which curve
crosses y axis.
sourcefn extremities(&self) -> CurveExtremities
fn extremities(&self) -> CurveExtremities
Find all extremities of the curve curve'(t)_x = 0 || curve'(t)_y = 0
Provided Methods§
sourcefn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIter ⓘ
Convert curve to an iterator over line segments with desired flatness
sourcefn split(&self) -> (Self, Self)
fn split(&self) -> (Self, Self)
Optimized version of Curve::split_at(0.5)
sourcefn param_at_length(&self, l: Scalar, error: Option<Scalar>) -> Scalar
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