Skip to main content

XYTCurve

Struct XYTCurve 

Source
pub struct XYTCurve { /* private fields */ }
Expand description

A smooth curve based on functions x(t) and y(t).

Implementations§

Source§

impl XYTCurve

Source

pub fn new(points: Vec<PointXYT>) -> Self

Interpolate an XYTCurve that will go through a set of points using lowest-degree polynomials for the internal x(t) and y(t) functions.

Source

pub fn evaluate(&self, t: f64) -> PointXYT

Evaluate the curve at a given t. Returns (x(t), y(t), t) as a PointXYT.

Source

pub fn derivative(&self) -> Self

Return the derivative of the curve. This can be thought of as the “velocity” at which a point moves down the curve as t increases at a constant rate.

Source

pub fn newtons_method_x( &self, x: f64, t_guess: f64, max_iterations: u16, ) -> PointXYT

Estimate a t at which curve.evaluate(t) will return (x, y(t), t) for a given x using Newton’s method. This requires a “guess” at this t value and a maximum number of iterations to perform when estimating t. See the documentation of newtons_method, the function which this calls internally, for more information.

Source

pub fn newtons_method_y( &self, y: f64, t_guess: f64, max_iterations: u16, ) -> PointXYT

Estimate a t at which curve.evaluate(t) will return (x(t), y, t) for a given y using Newton’s method. This requires a “guess” at this t value and a maximum number of iterations to perform when estimating t. See the documentation of newtons_method, the function which this calls internally, for more information.

Source

pub fn t_to_distance(&self, t: f64) -> f64

Calculates the distance along the curve between 0 and t.

Source

pub fn newtons_method_distance_to_t( &self, distance: f64, t_guess: f64, max_iterations: u16, ) -> f64

Uses Newton’s method to calculate t at a given distance along the curve. This requires an initial “guess” at this t and a maximum number of iterations to perform when estimating it. See the documentation of newtons_method, the function which this calls internally, for more information.

Trait Implementations§

Source§

impl Clone for XYTCurve

Source§

fn clone(&self) -> XYTCurve

Returns a duplicate 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 Debug for XYTCurve

Source§

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

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

impl PartialEq for XYTCurve

Source§

fn eq(&self, other: &XYTCurve) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for XYTCurve

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.