pub struct QuadraticBezier<P: Point> { /* private fields */ }

Implementations§

source§

impl<P> QuadraticBezier<P>where P: Point,

source

pub fn new(start: P, ctrl: P, end: P) -> Self

Creates a new instance of QuadraticBezier from the given control points

source

pub fn eval(&self, t: P::Scalar) -> P

Evaluates the quadratic bezier curve at ‘t’ using direct evaluation, which may not be numerically stable

source

pub fn eval_casteljau(&self, t: P::Scalar) -> P

Evaluates the cubic bezier curve at t using the numerically stable De Casteljau algorithm

source

pub fn control_points(&self) -> [P; 3]

source

pub fn split(&self, t: P::Scalar) -> (Self, Self)

source

pub fn axis(&self, t: P::Scalar, axis: usize) -> P::Scalar

Sample the a particular coordinate axis of the curve at t (expecting t between 0 and 1). Shortcut for curve.eval(t).axis(k) This function can panic! TODO may add something like const_assert for Point’s const DIM

source

pub fn derivative(&self) -> LineSegment<P>

Return the derivative curve. The derivative is also a bezier curve but of degree n-1. In the case of a quadratic derivative it is just a line segment which also implementes eval(), as it is just a linear bezier curve.

source

pub fn dd(&self, t: P::Scalar, axis: usize) -> P::Scalar

Direct Derivative - Sample the axis coordinate at ‘axis’ of the curve’s derivative at t without creating a new curve. This is a convenience function for .derivative().eval(t).axis(n)
Parameters: t: the sampling parameter on the curve interval [0..1] axis: the index of the coordinate axis [0..N] Returns: Scalar value of the points own type type F
May be deprecated in the future.
This function can cause out of bounds panic when axis is larger than dimension of P

source

pub fn arclen(&self, nsteps: usize) -> P::Scalar

Approximates the arc length of the curve by flattening it with straight line segments. This works quite well, at ~32 segments it should already provide an error < 0.5 Remember arclen also works by linear approximation, not the integral, so we have to accept error! This approximation is unfeasable if desired accuracy is greater than 2 decimal places

source

pub fn distance_to_point(&self, point: P) -> P::Scalar

Calculates the minimum distance between given ‘point’ and the curve. Uses two passes with the same amount of steps in t:

  1. coarse search over the whole curve
  2. fine search around the minimum yielded by the coarse search
source

pub fn baseline(&self) -> LineSegment<P>

Returns the line segment formed by the curve’s start and endpoint

source

pub fn is_linear(&self, tolerance: P::Scalar) -> bool

Checks if, given some tolerance, the curve can be considered equal to a line segment

source

pub fn is_a_point(&self, tolerance: P::Scalar) -> bool

Determines if, given some tolerance, the control points of the curve can be considered equal. If true, the curve is just a singular point

source

pub fn bounding_box(&self) -> [(P::Scalar, P::Scalar); P::DIM]

Return the bounding box of the curve as an array of (min, max) tuples for each dimension (its index)

Trait Implementations§

source§

impl<P: Clone + Point> Clone for QuadraticBezier<P>

source§

fn clone(&self) -> QuadraticBezier<P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<P: Debug + Point> Debug for QuadraticBezier<P>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<P> From<QuadraticBezier<P>> for BezierSegment<P>where P: Point,

source§

fn from(s: QuadraticBezier<P>) -> Self

Converts to this type from the input type.
source§

impl<P: PartialEq + Point> PartialEq<QuadraticBezier<P>> for QuadraticBezier<P>

source§

fn eq(&self, other: &QuadraticBezier<P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P: Copy + Point> Copy for QuadraticBezier<P>

source§

impl<P: Point> StructuralPartialEq for QuadraticBezier<P>

Auto Trait Implementations§

§

impl<P> RefUnwindSafe for QuadraticBezier<P>where P: RefUnwindSafe,

§

impl<P> Send for QuadraticBezier<P>where P: Send,

§

impl<P> Sync for QuadraticBezier<P>where P: Sync,

§

impl<P> Unpin for QuadraticBezier<P>where P: Unpin,

§

impl<P> UnwindSafe for QuadraticBezier<P>where P: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.