Skip to main content

Bspline

Struct Bspline 

Source
pub struct Bspline { /* private fields */ }
Expand description

Bicubic spline interpolator.

Use init() or the point-by-point API (init_num, add_point, prepare) to set up data, then get() or get_stateful() to evaluate.

Port of C++ agg::bspline.

Implementations§

Source§

impl Bspline

Source

pub fn new() -> Self

Create an empty spline.

Source

pub fn new_with_points(x: &[f64], y: &[f64]) -> Self

Create and initialize from arrays.

Source

pub fn init_num(&mut self, max: usize)

Initialize the spline storage for max points.

Source

pub fn add_point(&mut self, x: f64, y: f64)

Add a data point (call after init_num, before prepare).

Source

pub fn prepare(&mut self)

Compute the spline coefficients (call after adding all points).

Source

pub fn init(&mut self, x: &[f64], y: &[f64])

Initialize from x and y arrays.

Source

pub fn get(&self, x: f64) -> f64

Evaluate the spline at x (stateless binary search each call).

Source

pub fn get_stateful(&self, x: f64) -> f64

Evaluate the spline at x with cached index (faster for sequential access).

Trait Implementations§

Source§

impl Default for Bspline

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.