1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! B-spline curve trait definitions.
use crate::DType;
use crate::interpolate::error::InterpolateResult;
use numr::runtime::Runtime;
use numr::tensor::Tensor;
/// A parametric B-spline curve defined by control points and knot vector.
#[derive(Debug, Clone)]
pub struct BSplineCurve<R: Runtime<DType = DType>> {
/// Control points, shape `[n_points, n_dims]`.
pub control_points: Tensor<R>,
/// Knot vector, shape `[n_knots]`. Must be non-decreasing.
pub knots: Tensor<R>,
/// Polynomial degree.
pub degree: usize,
}
/// B-spline curve algorithms.
pub trait BSplineCurveAlgorithms<R: Runtime<DType = DType>> {
/// Evaluate the B-spline curve at parameter values t.
///
/// # Arguments
/// * `curve` - The B-spline curve
/// * `t` - 1D tensor of parameter values, shape `[m]`
///
/// # Returns
/// Points on the curve, shape `[m, n_dims]`
fn bspline_curve_evaluate(
&self,
curve: &BSplineCurve<R>,
t: &Tensor<R>,
) -> InterpolateResult<Tensor<R>>;
/// Evaluate the derivative of the B-spline curve at parameter values t.
///
/// # Arguments
/// * `order` - Derivative order (1 = first derivative, etc.)
fn bspline_curve_derivative(
&self,
curve: &BSplineCurve<R>,
t: &Tensor<R>,
order: usize,
) -> InterpolateResult<Tensor<R>>;
/// Subdivide the B-spline curve at parameter t via knot insertion.
fn bspline_curve_subdivide(
&self,
curve: &BSplineCurve<R>,
t: f64,
) -> InterpolateResult<(BSplineCurve<R>, BSplineCurve<R>)>;
}