pub struct BSpline {
pub control_points: Vec<[f64; 3]>,
pub knot_vector: Vec<f64>,
pub degree: usize,
}Expand description
A non-uniform B-spline curve defined by a knot vector and control points.
Uses the Cox–de Boor recursion for evaluation and supports knot insertion.
Fields§
§control_points: Vec<[f64; 3]>Control points.
knot_vector: Vec<f64>Knot vector (must have length = control_points.len() + degree + 1).
degree: usizePolynomial degree.
Implementations§
Source§impl BSpline
impl BSpline
Sourcepub fn new(
degree: usize,
control_points: Vec<[f64; 3]>,
knot_vector: Vec<f64>,
) -> Self
pub fn new( degree: usize, control_points: Vec<[f64; 3]>, knot_vector: Vec<f64>, ) -> Self
Construct a new B-spline curve.
§Panics
Panics if knot_vector.len() != control_points.len() + degree + 1.
Sourcepub fn clamped_uniform(degree: usize, control_points: Vec<[f64; 3]>) -> Self
pub fn clamped_uniform(degree: usize, control_points: Vec<[f64; 3]>) -> Self
Create a clamped uniform B-spline (interpolates first and last control points).
Sourcepub fn eval(&self, t: f64) -> [f64; 3]
pub fn eval(&self, t: f64) -> [f64; 3]
Evaluate the B-spline at parameter t using the de Boor algorithm.
Sourcepub fn insert_knot(&self, t_new: f64) -> Self
pub fn insert_knot(&self, t_new: f64) -> Self
Insert knot t_new into the knot vector (Boehm’s algorithm).
Returns a new BSpline with one additional control point and knot.
Auto Trait Implementations§
impl Freeze for BSpline
impl RefUnwindSafe for BSpline
impl Send for BSpline
impl Sync for BSpline
impl Unpin for BSpline
impl UnsafeUnpin for BSpline
impl UnwindSafe for BSpline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.