torchcurves.functional.bspline_curves#

torchcurves.functional.bspline_curves(u, control_points, knots=None, degree=3)#

Evaluate multiple B-Spline curves, each with its own control points, sharing the same knots and degree.

This function automatically handles backpropagation based on whether inputs require gradients: - Computes gradients only for inputs that require them using custom autograd.

Parameters:
  • u (Tensor) – A tensor of size \((B, C)\) of values between knots.min() and knots.max(), representing a mini-batch of \(B\) arguments for sampling each of the \(C\) curves.

  • control_points (Tensor) – A tensor of size \((M, C, D)\) describing \(M\) curves with \(C\) control points each, embedded in \(\mathbb{R}^D\).

  • knots (Optional[Tensor]) – A 1D tensor of size \(M + P + 1\) representing the spline function’s knot vector, where \(P\) is the degree of the piecewise polynomials defining the spline function. None means uniformly spaced augmented knots in \([-1, 1]\) with repeated boundary knots. (default: None)

  • degree (int) – The degree \(P\) of the B-Spline function. (default: 3 meaning a cubic spline)

Return type:

Tensor

Returns:

A tensor of size \((B, C, D)\), representing a mini-batch of size \(B\), corresponding to samples from \(C\) curves in \(\mathbb{R}^D\).