nurbspy.jax.prepared module#

Explicit reusable basis tables for fixed knots and evaluation parameters.

Preparation stores polynomial basis functions, not rational geometry. Control points and weights are supplied on every evaluation and remain differentiable. There is no hidden cache: rebuild a prepared object when knots, degree, sample locations or the required derivative orders change. If knots or parameters are optimization variables, keep preparation inside the differentiated function.

class nurbspy.jax.prepared.PreparedCurveBasis(basis: Array, degree: int, n_control: int, max_order: int)[source]#

Bases: Module

Reusable polynomial curve basis tables, constructed by prepare_curve.

basis has shape (min(degree,max_order)+1, n_control, n_samples). No control points or weights are retained. Omitting W means unit weights, including when the curve used for preparation originally had other weights. Evaluation can use any positive spatial dimension at the same control count.

Methods

get_curvature(P[, W])

Return unsigned curvature of a regular planar or spatial curve.

get_derivative(P[, W, order])

Evaluate one static derivative order within the prepared maximum.

get_derivatives(P[, W])

Return all partials through max_order, shape (max_order+1,ndim,N).

get_tangent(P[, W])

Return unit tangents; undefined at zero speed.

get_value(P[, W])

Evaluate supplied geometry, returning (ndim,n_samples).

basis: Array#
degree: int#
get_curvature(P, W=None)[source]#

Return unsigned curvature of a regular planar or spatial curve.

get_derivative(P, W=None, order=1)[source]#

Evaluate one static derivative order within the prepared maximum.

get_derivatives(P, W=None)[source]#

Return all partials through max_order, shape (max_order+1,ndim,N).

get_tangent(P, W=None)[source]#

Return unit tangents; undefined at zero speed.

get_value(P, W=None)[source]#

Evaluate supplied geometry, returning (ndim,n_samples).

max_order: int#
n_control: int#
class nurbspy.jax.prepared.PreparedSurfaceBasis(basis_u: Array, basis_v: Array, degree_u: int, degree_v: int, n_control_u: int, n_control_v: int, max_order_u: int, max_order_v: int, grid: bool)[source]#

Bases: Module

Reusable factorized surface tables, constructed by prepare_surface.

Paired output has shape (ndim,N). Grid output has shape (ndim,Nu_samples,Nv_samples) in ij ordering. Derivative tables prepend (max_order_u+1,max_order_v+1). P/W remain dynamic; no geometry is stored.

Methods

get_curvature(P[, W])

Return (signed mean, Gaussian) curvature of a regular 3D surface.

get_derivative(P[, W, order_u, order_v])

Evaluate one mixed partial with static orders within prepared limits.

get_derivatives(P[, W])

Return the complete rectangle of prepared rational mixed partials.

get_normals(P[, W])

Return unit oriented normals; requires a regular 3D surface.

get_value(P[, W])

Evaluate supplied geometry at fixed paired points or a tensor grid.

basis_u: Array#
basis_v: Array#
degree_u: int#
degree_v: int#
get_curvature(P, W=None)[source]#

Return (signed mean, Gaussian) curvature of a regular 3D surface.

get_derivative(P, W=None, order_u=1, order_v=0)[source]#

Evaluate one mixed partial with static orders within prepared limits.

get_derivatives(P, W=None)[source]#

Return the complete rectangle of prepared rational mixed partials.

get_normals(P, W=None)[source]#

Return unit oriented normals; requires a regular 3D surface.

get_value(P, W=None)[source]#

Evaluate supplied geometry at fixed paired points or a tensor grid.

grid: bool#
max_order_u: int#
max_order_v: int#
n_control_u: int#
n_control_v: int#
nurbspy.jax.prepared.prepare_curve(curve, u, max_order=2)[source]#

Prepare polynomial basis rows for a curve’s fixed knots and samples.

Only degree, knots and control count are read from curve. Its points and weights are not retained. Supply both explicitly at evaluation for rational geometry. max_order is a static nonnegative integer and may exceed degree. Include this call inside AD when differentiating knots or sample parameters; preparing once outside that function intentionally fixes those inputs.

nurbspy.jax.prepared.prepare_surface(surface, u, v, max_order_u=2, max_order_v=2, *, grid=False)[source]#

Prepare factorized polynomial basis rows for fixed surface parameters.

grid=False uses scalar or equal-length paired arrays, like NurbsSurface. grid=True uses independent 1D u/v axes and returns an ij tensor grid. Only 1D basis tables are stored in either mode. Control points and rational weights are always explicit evaluation inputs. Rebuild for new knots/samples; include preparation inside AD if their sensitivities are required.