Expand description
Quadratic bezier curve
Polynomial form:
(1 - t) ^ 2 * p0 + 2 * (1 - t) * t * p1 + t ^ 2 * p2
Matrix from:
┌ ┐ ┌ ┐
┌ ┐ │ 1 0 0 │ │ p0 │
│ 1 t t^2 │ │ -2 2 0 │ │ p1 │
└ ┘ │ 1 -2 1 │ │ p2 │
└ ┘ └ ┘
Tuple Fields
0: [Point; 3]
Implementations
Trait Implementations
sourceimpl Curve for Quad
impl Curve for Quad
sourcefn flatness(&self) -> Scalar
fn flatness(&self) -> Scalar
Flatness criteria for the cubic curve
It is equal to f = max d(t) where d(t) = |q(t) - l(t)|, l(t) = (1 - t) * p0 + t * p2
for q(t) bezier2 curve with p{0..2} control points, in other words maximum distance
from parametric line to bezier2 curve for the same parameter t.
Line can be represented as bezier2 curve, if p1 = (p0 + p2) / 2.0
.
Grouping polynomial coefficients:
q(t) = t^2 p2 + 2 (1 - t) t p1 + (1 - t)^2 p0
l(t) = t^2 p2 + (1 - t) t (p0 + p2) + (1 - t)^2 p0
d(t) = |q(t) - l(t)| = (1 - t) t |2 * p1 - p0 - p2|
f = 1 / 4 * | 2 p1 - p0 - p2 |
f^2 = 1/16 |2 * p1 - p0 - p2|^2
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. 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 Quad
impl StructuralPartialEq for Quad
Auto Trait Implementations
impl RefUnwindSafe for Quad
impl Send for Quad
impl Sync for Quad
impl Unpin for Quad
impl UnwindSafe for Quad
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