pub struct Quad(pub [Point; 3]);
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§
source§impl Curve for Quad
impl Curve for Quad
source§fn 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
source§fn split(&self) -> (Self, Self)
fn split(&self) -> (Self, Self)
Optimized version of split_at(0.5)
source§fn deriv(&self) -> Segment
fn deriv(&self) -> Segment
Derivative with respect to t,
deriv(t) = [curve'(t)_x, curve'(t)_y]
source§fn split_at(&self, t: Scalar) -> (Self, Self)
fn split_at(&self, t: Scalar) -> (Self, Self)
Split the curve at parameter value
t
source§fn 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
source§fn bbox(&self, init: Option<BBox>) -> BBox
fn bbox(&self, init: Option<BBox>) -> BBox
Extend provided
init
bounding box with the bounding box of the curvesource§fn 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
containersource§fn reverse(&self) -> Self
fn reverse(&self) -> Self
Identical curve but directed from end to start, instead of start to end.
source§fn 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.source§fn extremities(&self) -> CurveExtremities
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
fn length(&self, t0: Scalar, t1: Scalar) -> Scalar
Calculate length of the curve from
t0
to t1
source§impl PartialEq for Quad
impl PartialEq for Quad
impl Copy for Quad
impl StructuralPartialEq for Quad
Auto Trait Implementations§
impl Freeze for Quad
impl RefUnwindSafe for Quad
impl Send for Quad
impl Sync for Quad
impl Unpin for Quad
impl UnwindSafe for Quad
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more