splinepy.rational_bezier.RationalBezier#

class splinepy.rational_bezier.RationalBezier(degrees=None, control_points=None, weights=None, spline=None)[source]#

Bases: BezierBase

RationalBezier (Spline).

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

Rational Beziers are an extension to classical Beziers, similar like NURBS are an extension to B-Splines. By introducing a scalar weighting function \(W:\mathbb{R}^{N_{param}}\to\mathbb{R}^{+}_{*}\), we can construct modified (rational) basis functions, that allow to define rational Beziers. For a one-dimensional parameter space (\(N_{param}=1\)), this weighting function reads

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

with scalar weights \(w^i\in\mathbb{R}^{+}_{*}\). Consequently, for the two-dimensional case (\(N_{param}=2\)) we have

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

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

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

We proceed with a description of how to construct rational Beziers:

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 rational Bezier 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 (i.e., \(N_{param}=1\)) corresponds to a line embedded into the physical space

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

with the modified (rational) basis functions

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

2. A rational Bezier 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 (i.e., \(N_{param}=2\)) corresponds to a surface embedded into the physical space

\[S(u,v) = \sum_{i=0}^{l} \sum_{j=0}^{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 rational Bezier 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 (i.e., \(N_{param}=3\)) corresponds to a volume embedded into the physical space

\[V(u,v,w) = \sum_{i=0}^{l} \sum_{j=0}^{m} \sum_{k=0}^{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:

# Rational bezier curve (quarter arc)
rational_bezier = splinepy.RationalBezier(
    degrees=[2],
    control_points=[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0]],
    weights=[1.0, 2.0**-0.5, 1.0],
)
Parameters:
  • degrees ((para_dim,) array-like)

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

  • weights

  • spline (Spline)

Return type:

None

Methods

RationalBezier.basis(queries[, nthreads])

Returns basis function values on the supports of given queries.

RationalBezier.basis_and_support(queries[, ...])

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

RationalBezier.basis_derivative(queries, orders)

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

RationalBezier.basis_derivative_and_support(...)

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

RationalBezier.clear()

Clears core spline and saved data

RationalBezier.compose(inner_function[, ...])

Calculates the spline that forms the composition of the inner function spline (function argument), using the caller spline as the outer (or deformation function).

RationalBezier.composition_derivative(inner, ...)

Derivative of composition when given the differentiated inner function with constant outer function.

RationalBezier.copy([saved_data])

Returns deepcopy of stored data and newly initialized self.

RationalBezier.current_core_properties(self)

RationalBezier.derivative(queries, orders[, ...])

Evaluates derivatives of spline.

RationalBezier.derivative_spline(orders)

Calculates the spline that describes the requested derivative in a close-form representation of the the same spline-type.

RationalBezier.elevate_degrees(...)

Elevate degree.

RationalBezier.evaluate(queries[, nthreads])

Evaluates spline.

RationalBezier.export(fname)

Export spline.

RationalBezier.extract_dim(dim)

Extracts a single physical dimension of a spline.

RationalBezier.greville_abscissae([...])

Returns greville abscissae.

RationalBezier.jacobian(queries[, nthreads])

Evaluates jacobians on spline.

RationalBezier.mapper(reference)

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

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

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

RationalBezier.reduce_degrees(...[, tolerance])

Tries to reduce degree.

RationalBezier.sample(resolutions[, nthreads])

Uniformly sample along each parametric dimensions from spline.

RationalBezier.show(**kwargs)

Equivalent to

RationalBezier.showable(**kwargs)

Equivalent to

RationalBezier.split(para_dim, locations)

Splits spline at given locations along the given para_dim.

RationalBezier.support(queries[, nthreads])

Returns basis support ids of given queries.

RationalBezier.todict([tolist])

Return current spline as dict.

Attributes

RationalBezier.nurbs

RationalBezier.rationalbezier