pub trait Curve<F: Float, P: CurvePoint<F>> {
Show 13 methods
// Required methods
fn value_at(&self, t: F) -> P;
fn tangent_at(&self, t: F) -> P;
fn estimate_length(&self, precision: F) -> F
where P: Distance<F>;
// Provided methods
fn start_point(&self) -> P { ... }
fn end_point(&self) -> P { ... }
fn dot(p0: P) -> Bezier0<F, P> { ... }
fn line(p0: P, p1: P) -> Bezier1<F, P> { ... }
fn quad_bezier(p0: P, p1: P, p2: P) -> Bezier2<F, P> { ... }
fn cubic_bezier(p0: P, p1: P, p2: P, p3: P) -> Bezier3<F, P> { ... }
fn into_iter(self, steps_count: usize) -> CurveIterator<F, P, Self>
where Self: Sized { ... }
fn into_iter_inclusive(
self,
steps_count: usize,
) -> CurveIterator<F, P, Self>
where Self: Sized { ... }
fn composed_curve(start_point: P) -> ComposedCurve<F, P> { ... }
fn linear_speed(
self,
table_size: usize,
steps_count: usize,
) -> LinearSpeed<F, P, Self>
where P: Distance<F>,
Self: Sized { ... }
}
Expand description
A curve is a parametric function that maps a value t
in range from 0 to 1 to a point in space.
Required Methods§
Sourcefn tangent_at(&self, t: F) -> P
fn tangent_at(&self, t: F) -> P
Get the derivative at a given value t
in range from 0 to 1.
Sourcefn estimate_length(&self, precision: F) -> Fwhere
P: Distance<F>,
fn estimate_length(&self, precision: F) -> Fwhere
P: Distance<F>,
Estimate the length of the curve as an average between min
and max
estimation.
The precision parameter is the maximum ration of min
and max
estimation.
Precision:
- F::infinity() - means that estimation will be done in one step,
- 1.0 - means that
max / min
should be less than100%
, - 0.5 - the same as above, but the difference is
50%
, - 0.1 - the same as above, but the difference is
10%
, - and so on…
Provided Methods§
fn start_point(&self) -> P
fn end_point(&self) -> P
Sourcefn quad_bezier(p0: P, p1: P, p2: P) -> Bezier2<F, P>
fn quad_bezier(p0: P, p1: P, p2: P) -> Bezier2<F, P>
Create a quadratic bezier curve
Sourcefn cubic_bezier(p0: P, p1: P, p2: P, p3: P) -> Bezier3<F, P>
fn cubic_bezier(p0: P, p1: P, p2: P, p3: P) -> Bezier3<F, P>
Create a cubic bezier curve
Sourcefn into_iter(self, steps_count: usize) -> CurveIterator<F, P, Self>where
Self: Sized,
fn into_iter(self, steps_count: usize) -> CurveIterator<F, P, Self>where
Self: Sized,
Create an iterator that will generate points on the curve.
Sourcefn into_iter_inclusive(self, steps_count: usize) -> CurveIterator<F, P, Self>where
Self: Sized,
fn into_iter_inclusive(self, steps_count: usize) -> CurveIterator<F, P, Self>where
Self: Sized,
Create an iterator that will generate points on the curve, including the last point.
Sourcefn composed_curve(start_point: P) -> ComposedCurve<F, P>
fn composed_curve(start_point: P) -> ComposedCurve<F, P>
Create a composed curve that will be a sequence of curves.
Each segment of the curve will be represented by equal t
range.
For example, if you have 3 curves, they will take t
ranges: 0 - 0.33
, 0.33 - 0.66
and 0.66 - 1.0
.
Sourcefn linear_speed(
self,
table_size: usize,
steps_count: usize,
) -> LinearSpeed<F, P, Self>
fn linear_speed( self, table_size: usize, steps_count: usize, ) -> LinearSpeed<F, P, Self>
Create a linear speed curve that will allow to move with a constant speed along the curve. It’s especially useful when you want to animate the movement along a composed curve.
Arguments:
table_size
- the size of the table that will be used to speed up the calculations, the bigger means the better the precision.steps_count
- the number of steps that will be used to calculate the table, so if you have 3 steps then the curve points will be calculated at 0.0, 0.5 and 1.0. Intermediate points will be interpolated.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.