Expand description
Cubic bezier curve
Polynomial form:
(1 - t) ^ 3 * p0 + 3 * (1 - t) ^ 2 * t * p1 + 3 * (1 - t) * t ^ 2 * p2 + t ^ 3 * p3
Matrix from:
┌ ┐ ┌ ┐
┌ ┐ │ 1 0 0 0 │ │ p0 │
│ 1 t t^2 t^3 │ │ -3 3 0 0 │ │ p1 │
└ ┘ │ 3 -6 3 0 │ │ p2 │
│ -1 3 -3 1 │ │ p3 │
└ ┘ └ ┘
Tuple Fields
0: [Point; 4]
Implementations
Trait Implementations
sourceimpl Curve for Cubic
impl Curve for Cubic
sourcefn flatness(&self) -> Scalar
fn flatness(&self) -> Scalar
Flatness criteria for the cubic curve
This function actually returns 16 * flatness^2
It is equal to f = max d(t) where d(t) = |c(t) - l(t)|, l(t) = (1 - t) * c0 + t * c3
for c(t) bezier3 curve with c{0..3} control points, in other words maximum distance
from parametric line to bezier3 curve for the same parameter t. It is shown in the article
that:
f^2 <= 1/16 (max{u_x^2, v_x^2} + max{u_y^2, v_y^2})
where:
u = 3 * b1 - 2 * b0 - b3
v = 3 * b2 - b0 - 2 * b3
f == 0
means completely flat so estimating upper bound is sufficient as splitting more
than needed is not a problem for rendering.
sourcefn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
fn offset(&self, dist: Scalar, out: &mut impl Extend<Segment>)
Offset cubic bezier curve with a list of cubic curves
Offset bezier curve using Tiller-Hanson method. In short, it will just offset line segment corresponding to control points, then find intersection of this lines and treat them as new control points.
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 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. Read more
sourcefn extremities(&self) -> CurveExtremities
fn extremities(&self) -> CurveExtremities
Find all extremities of the curve curve'(t)_x = 0 || curve'(t)_y = 0
sourcefn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIterⓘNotable traits for CurveFlattenIterimpl Iterator for CurveFlattenIter type Item = Line;
fn flatten(&self, tr: Transform, flatness: Scalar) -> CurveFlattenIterⓘNotable traits for CurveFlattenIterimpl Iterator for CurveFlattenIter type Item = Line;
Convert curve to an iterator over line segments with desired flatness
impl Copy for Cubic
impl StructuralPartialEq for Cubic
Auto Trait Implementations
impl RefUnwindSafe for Cubic
impl Send for Cubic
impl Sync for Cubic
impl Unpin for Cubic
impl UnwindSafe for Cubic
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more