pub struct XYTCurve { /* private fields */ }Expand description
A smooth curve based on functions x(t) and y(t).
Implementations§
Source§impl XYTCurve
impl XYTCurve
Sourcepub fn new(points: Vec<PointXYT>) -> Self
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.
Sourcepub fn evaluate(&self, t: f64) -> PointXYT
pub fn evaluate(&self, t: f64) -> PointXYT
Evaluate the curve at a given t. Returns (x(t), y(t), t) as a PointXYT.
Sourcepub fn derivative(&self) -> Self
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.
Sourcepub fn newtons_method_x(
&self,
x: f64,
t_guess: f64,
max_iterations: u16,
) -> PointXYT
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.
Sourcepub fn newtons_method_y(
&self,
y: f64,
t_guess: f64,
max_iterations: u16,
) -> PointXYT
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.
Sourcepub fn t_to_distance(&self, t: f64) -> f64
pub fn t_to_distance(&self, t: f64) -> f64
Calculates the distance along the curve between 0 and t.
Sourcepub fn newtons_method_distance_to_t(
&self,
distance: f64,
t_guess: f64,
max_iterations: u16,
) -> f64
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.