Enum bezier_rs::TValue

source ·
pub enum TValue {
    Parametric(f64),
    Euclidean(f64),
    EuclideanWithinError {
        t: f64,
        error: f64,
    },
}
Expand description

A structure which can be used to reference a particular point along a Bezier. Assuming a 2-dimensional Bezier is represented as a parametric curve defined by components (x(f(t), y(f(t)))), this structure defines variants for f(t).

  • The Parametric variant represents the point calculated using the parametric equation of the curve at argument t. That is, f(t) = t. Speed along the curve’s parametric form is not constant. t must lie in the range [0, 1].
  • The Euclidean variant represents the point calculated at a distance ratio t along the arc length of the curve in the range [0, 1]. Speed is constant along the curve’s arc length.
    • E.g. If d is the distance from the start point of a Bezier to a certain point along the curve, and l is the total arc length of the curve, that certain point lies at a distance ratio t = d / l.
    • All Bezier functions will implicitly convert a Euclidean TValue argument to a parametric t-value using binary search, computed within a particular error. That is, a point at distance ratio t*, satisfying |t* - t| <= error. The default error is 0.001. Given this requires a lengthier calculation, it is not recommended to use the Euclidean or EuclideanWithinError variants frequently in computationally intensive tasks.
  • The EuclideanWithinError variant functions exactly as the Euclidean variant, but allows the error to be customized when computing t internally.

Variants§

§

Parametric(f64)

§

Euclidean(f64)

§

EuclideanWithinError

Fields

§error: f64

Trait Implementations§

source§

impl Clone for TValue

source§

fn clone(&self) -> TValue

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 PartialEq for TValue

source§

fn eq(&self, other: &TValue) -> 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 Copy for TValue

source§

impl StructuralPartialEq for TValue

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.