splinepy.nurbs.NURBS#

class splinepy.nurbs.NURBS(degrees=None, knot_vectors=None, control_points=None, weights=None, spline=None)[source]#

Bases: BSplineBase

Non-Uniform Rational B-Spline.

Passes all arguments to super.__init__(), see BSplineBase.

NURBS are an extension of B-Splines overcoming their drawback of being unable to represent circular shapes. This is achieved by the introduction of a weighting function \(W:\mathbb{R}^{N_{param}}\to\mathbb{R}^{+}_{*}\), defined as (for a one-dimensional parameter space, i.e., \(N_{param}=1\))

\[W(u) = \sum_{i=1}^{l} N^{i;p}(u) w^i\]

with scalar weights \(w^i\in\mathbb{R}^{+}_{*}\). Note, that the same basis functions are used for both the weighting function and projection space. Consequently, for the two-dimensional case (\(N_{param}=2\)) we have

\[W(u,v) = \sum_{i=1}^{l} \sum_{j=1}^{m} N^{i;p}(u) N^{j;q}(v) w^{i,j}\]

and for the three-dimensional case (\(N_{param}=3\))

\[W(u,v,w) = \sum_{i=1}^{l} \sum_{j=1}^{m} \sum_{k=1}^{n} N^{i;p}(u) N^{j;q}(v) N^{k;r}(w) w^{i,j,k}\]

We can now construct different spline embeddings similar to the description in BSplineBase, only including the additional weighting:

Note

For simplicity, we restrict ourselves to the three most common types of splines in the following, namely curves, surfaces and volumes, although splinepy also supports higher dimensions, see the documentation of Spline for more information.

1. A NURBS of degree \(p\) with control points \(P^i\in\mathbb{R}^{N_{phys}}\), weights \(w^i\in\mathbb{R}^{+}_{*}\), and a one-dimensional parameter space (\(N_{param}=1\)) corresponds to a line, embedded into the physical space:

\[C(u) = \sum_{i=1}^{l} R^{i;p}(u) P^i\]

with the modified (rational) basis functions

\[R^{i;p}(u) = \frac{N^{i;p}(u)w^i}{W(u)}\]

2. A NURBS of degrees \(p,q\) with control points \(P^{i,j}\in\mathbb{R}^{N_{phys}}\), weights \(w^{i,j}\in\mathbb{R}^{+}_{*}\), and a two-dimensional parameter space (\(N_{param}=2\)) corresponds to a surface, embedded into the physical space:

\[S(u,v) = \sum_{i=1}^{l} \sum_{j=1}^{m} R^{i,j;p,q}(u,v) P^{i,j}\]

with the modified (rational) basis functions

\[R^{i,j;p,q}(u,v) = \frac{\tilde{N}^{i,j;p,q}(u,v) w^{i,j}}{W(u,v)}\]

3. A NURBS of degrees \(p,q,r\) with control points \(P^{i,j,k}\in\mathbb{R}^{N_{phys}}\), weights \(w^{i,j,k}\in\mathbb{R}^{+}_{*}\), and a three-dimensional parameter space (\(N_{param}=3\)) corresponds to a volume, embedded into the physical space:

\[V(u,v,w) = \sum_{i=1}^{l} \sum_{j=1}^{m} \sum_{k=1}^{n} R^{i,j,k;p,q,r}(u,v,w) P^{i,j,k}\]

with the modified (rational) basis functions

\[R^{i,j,k;p,q,r}(u,v,w) = \frac{ \tilde{N}^{i,j,k;p,q,r}(u,v,w) w^{i,j,k} }{ W(u,v,w) }\]

Higher-dimensional instances are constructed accordingly.

Usage:

# NURBS curve (circle)
nurbs_curve = splinepy.NURBS(
    degrees=[2],
    knot_vectors=[
        0.0,
        0.0,
        0.0,
        0.25,
        0.25,
        0.5,
        0.5,
        0.75,
        0.75,
        1.0,
        1.0,
        1.0,
    ],
    control_points=[
        [1.0, 0.0],
        [1.0, 1.0],
        [0.0, 1.0],
        [-1.0, 1.0],
        [-1.0, 0.0],
        [-1.0, -1.0],
        [0.0, -1.0],
        [1.0, -1.0],
        [1.0, 0.0],
    ],
)
Parameters:
  • degrees ((para_dim,) list-like)

  • knot_vectors ((para_dim, n) list)

  • control_points ((m, dim) list-like)

  • weights ((m,) list-like)

Return type:

None

Methods

NURBS.basis(queries[, nthreads])

Returns basis function values on the supports of given queries.

NURBS.basis_and_support(queries[, nthreads])

Returns basis function values and their support ids of given queries.

NURBS.basis_derivative(queries, orders[, ...])

Returns derivative of basis functions evaluated on the supports of given queries.

NURBS.basis_derivative_and_support(queries, ...)

Returns derivative of basis functions and their support ids of given queries.

NURBS.clear()

Clears core spline and saved data

NURBS.copy([saved_data])

Returns deepcopy of stored data and newly initialized self.

NURBS.current_core_properties(self)

NURBS.derivative(queries, orders[, nthreads])

Evaluates derivatives of spline.

NURBS.elevate_degrees(parametric_dimensions)

Elevate degree.

NURBS.evaluate(queries[, nthreads])

Evaluates spline.

NURBS.export(fname)

Export spline.

NURBS.extract_bezier_patches()

Extract all knot spans as Bezier patches to perform further operations such as compositions and multiplications

NURBS.greville_abscissae([duplicate_tolerance])

Returns greville abscissae.

NURBS.insert_knots(parametric_dimension, knots)

Inserts knots.

NURBS.jacobian(queries[, nthreads])

Evaluates jacobians on spline.

NURBS.knot_insertion_matrix([...])

Returns knot insertion matrix for a given set of knots in a specific parametric domain, if bezier flag is set, returns matrix, that creates C^(-1) spline spaces.

NURBS.mapper(reference)

Retrieve a mapper that can be used to get physical derivatives such as a gradient or hessian in physical space

NURBS.normalize_knot_vectors()

Sets all knot vectors into a range of [0,1], if applicable

NURBS.proximities(queries[, ...])

Given physical coordinate, finds a parametric coordinate that maps to the nearest physical coordinate.

NURBS.reduce_degrees(parametric_dimensions)

Tries to reduce degree.

NURBS.remove_knots(parametric_dimension, knots)

Tries to removes knots.

NURBS.sample(resolutions[, nthreads])

Uniformly sample along each parametric dimensions from spline.

NURBS.show(**kwargs)

Equivalent to

NURBS.showable(**kwargs)

Equivalent to

NURBS.support(queries[, nthreads])

Returns basis support ids of given queries.

NURBS.todict([tolist])

Return current spline as dict.

NURBS.uniform_refine([para_dims, n_knots])

Uniformly refines all knot-spans in given direction(s) by given degree(s).

Attributes

NURBS.nurbs