m3sh.obj.CSType.

bspline#

static CSType.bspline(t, c, k, *args)#

Initialize B-spline curve/surface.

Initializes a B-spline curve/surface using a (t, c, k) triple as in scipy.interpolate.BSpline.

Parameters:
t~numpy.ndarray, shape (2k+n+2,)

Knot vector of a curve. For a surface a pair of knot vectors with shapes (2k+m+2,) and (2l+n+2,) have to be specified.

c~numpy.ndarray, shape (k+n+1, d)

Control point array. For a surface an array of shape (k+m+1, l+n+1, d) is required.

kint

The degree of the curve. For a surface a pair (k, l) of integers is required.

*args

Variable length argument list. Pass 'rational' to indicate that the last of the d coordinate entries of each control point is a weight.

Returns:
CSType

Corresponding B-spline curve/surface representation.

Raises:
ValueError

If the values and size given for degree, knots, and control points are inconsistent.

Examples

Curves. Let \(n \geq 0\). Control points \(\mathbf{c}_0, \dots, \mathbf{c}_{k+n} \in \mathbb{R}^d\) and knots \(t_0, \dots, t_{2k+n+1} \in \mathbb{R}\) such that \(t_i \leq t_{i+1}\) define a B-spline curve

\[\mathbf{c}(t) = \sum_{i=0}^{n+k} \mathbf{c}_i N_i^k(t)\]

of degree \(k\) over the interval \([t_k, t_{k+n+1})\) if \(t_i < t_{i+k+1}\) for \(i \in \{0, \dots, n+k\}\). Those values can be passed as arguments by packing the control points into an array c of shape (k+n+2, d) and knots as an array t of shape (2k+n+2,) or as list[float].

The curve \(\mathbf{c}\) is polynomial over each non empty interval \([t_j, t_{j+1})\) for \(j = k, \dots, k+n\). The integer \(n\) determines the number of polynomial segments of \(\mathbf{c}\).

Surfaces. Let \(m \geq 0\) and \(n \geq 0\). A tensor product B-spline surface of degree \((k, l)\) over the knot sequences \(u_0, \dots, u_{2k+n+1}\) and \(v_0, \dots, v_{2l+m+1}\) is defined as

\[\mathbf{s}(u,v) = \sum_{i=0}^{m+k} \sum_{j=0}^{n+l} \mathbf{c}_{ij} N_i^k(u) N_j^l(v).\]

The control points can be stored in an array of shape (k+m+1, l+n+1, d). Knot vectors can be passed as a pair of 1-dimensional arrays or a pair of list[float].