Module enterpolation::linear
source · Expand description
Linear and quasi-linear interpolations.
The easist way to create a linear interpolation is by using the builder pattern of LinearBuilder
.
let linear = Linear::builder()
.elements([0.0,5.0,3.0])
.knots([0.0,1.0,2.0])
.build()?;
let results = [0.0,2.5,5.0,4.0,3.0];
for (value,result) in linear.take(5).zip(results.iter().copied()){
assert_f64_near!(value, result);
}
Linear interplations are one of the simplest forms of interpolations.
Most of the time, linear interpolations are used as an approximation of some smoother curve,
such they often have many elements.
For this reason the equidistant()
method on the builder is recommended.
Linear
is always linear in its output but not necessarily in its input. In that case, we
say that the interpolation is quasi-linear.
One can imagine a linear interpolation between 2D points. Then quasi-linearity means that
the curve consists of lines between the given 2D points but its velocity may change non-linear.
To achieve a non-linear interpolation, the easing()
method on the builder may be used.
Linear equidistant constant interpolations are often wanted to define some specific curve
(like a specific gradient). To create such interpolation, the builder pattern can not be used yet.
Instead one should create a linear interpolation directly with its equidistant_unchecked()
constructor.
Re-exports
pub use error::KnotElementInequality;
pub use error::LinearError;
pub use error::NotSorted;
pub use error::TooFewElements;
Modules
- All error types for linear interpolation.
Structs
- Linear Interpolation.
- Builder for linear interpolation.
- Builder for linear interpolation.
Type Definitions
- An array-allocated, const-creatable, linear interpolation with equidistant knot distribution.