Struct enterpolation::bspline::BSpline
source · pub struct BSpline<K, E, S> { /* private fields */ }
Expand description
BSpline curve.
See bspline module for more information.
Implementations§
source§impl BSpline<Unknown, Unknown, Unknown>
impl BSpline<Unknown, Unknown, Unknown>
sourcepub fn builder() -> BSplineBuilder<Unknown, Unknown, Unknown, Unknown, Open>
pub fn builder() -> BSplineBuilder<Unknown, Unknown, Unknown, Unknown, Open>
Get a builder for bsplines.
The builder takes:
- a mode, either
open()
, which is default,clamped()
orlegacy()
- elements with
elements()
orelements_with_weights()
- knots with
knots()
orequidistant()
- the kind of workspace to use with
dynamic()
,constant()
orworkspace()
Examples
let bez = BSpline::builder()
.clamped()
.elements([20.0,100.0,0.0,200.0])
.equidistant::<f64>()
.degree(3)
.normalized()
.constant::<4>() // degree + 1
.build()?;
let mut iter = bez.take(5);
let expected = [20.0,53.75,65.0,98.75,200.0];
for i in 0..=4 {
let val = iter.next().unwrap();
assert_f64_near!(val, expected[i]);
}
source§impl<K, E, S> BSpline<K, E, S>where
E: DiscreteGenerator,
K: SortedGenerator,
S: Space<E::Output>,
impl<K, E, S> BSpline<K, E, S>where E: DiscreteGenerator, K: SortedGenerator, S: Space<E::Output>,
sourcepub fn new(elements: E, knots: K, space: S) -> Result<Self, BSplineError>
pub fn new(elements: E, knots: K, space: S) -> Result<Self, BSplineError>
Creates a bspline curve of elements and knots given.
The resulting degree of the curve is elements.len() - knots.len() +1
.
The domain for the curve with degree p
is knots[p-1]
and knots[knots.len() - p -2]
.
The knots have to be sorted.
Errors
TooFewElements
if there are less than two elements.
InvalidDegree
if degree is not at least 1 and at most the number of elements - 1.
TooSmallWorkspace
if the workspace is not bigger than the degree of the curve.
IncongruousElementsKnots
either if the amount of knots is less than the amount of elements
or if the anoumt of knots is more than double the amount of elements.
source§impl<K, E, S> BSpline<K, E, S>where
E: DiscreteGenerator,
K: SortedGenerator,
S: Space<E::Output>,
impl<K, E, S> BSpline<K, E, S>where E: DiscreteGenerator, K: SortedGenerator, S: Space<E::Output>,
sourcepub fn new_unchecked(elements: E, knots: K, space: S) -> Self
pub fn new_unchecked(elements: E, knots: K, space: S) -> Self
Creates a bspline curve of elements and knots given.
The resulting degree of the curve is elements.len() - knots.len() + 1
.
The domain for the curve with degree p
is knots[p-1]
and knots[knots.len() - p -2]
.
The knots have to be sorted.
Panics
The degree has to be at least 1, otherwise the library may panic at any time.