Spline Surface#
- class SplineSurface(orders, knots_u=None, knots_v=None, control_points=None)[source]#
Bases:
ModuleThe bivariate B-Spline surface model class.
A bivariate B-spline surface is a parametric surface defined as the tensor product of two univariate B-spline curves:
\[S(x, y) = \sum_{i,j=1}^{n_x, n_y} B_{i,k}(x) B_{j,s}(y) C_{i,j}, \quad x \in [x_1, x_m], y \in [y_1, y_l]\]where:
\(C_{i,j} \in \mathbb{R}^2\) are the control points. These fixed points influence the shape of the surface but are not generally interpolated, except at the boundaries under certain knot multiplicities.
\(B_{i,k}(x)\) and \(B_{j,s}(y)\) are the B-spline basis functions defined over two orthogonal directions, with orders \(k\) and \(s\), respectively.
\(X = \{ x_1, x_2, \dots, x_m \}\) and \(Y = \{ y_1, y_2, \dots, y_l \}\) are the non-decreasing knot vectors along the two directions.
Initialization of the
SplineSurfaceclass.- Parameters:
orders (list[int]) – The orders of the spline along each parametric direction. Each order defines the degree of the corresponding basis as
degree = order - 1.knots_u (torch.Tensor | dict) – The knots of the spline along the first direction. For details on valid formats and initialization modes, see the
Splineclass. Default is None.knots_v (torch.Tensor | dict) – The knots of the spline along the second direction. For details on valid formats and initialization modes, see the
Splineclass. Default is None.control_points (torch.Tensor) – The control points defining the surface geometry. It must be a two-dimensional tensor of shape
[len(knots_u) - orders[0], len(knots_v) - orders[1]]. If None, they are initialized as learnable parameters with zero values. Default is None.
- Raises:
ValueError – If
ordersis not a list of integers.ValueError – If
knots_uis neither a torch.Tensor nor a dictionary, when provided.ValueError – If
knots_vis neither a torch.Tensor nor a dictionary, when provided.ValueError – If
control_pointsis not a torch.Tensor, when provided.ValueError – If
ordersis not a list of two elements.ValueError – If
knots_u,knots_v, andcontrol_pointsare all None.
- forward(x)[source]#
Forward pass for the
SplineSurfacemodel.- Parameters:
x (torch.Tensor | LabelTensor) – The input tensor.
- Returns:
The output tensor.
- Return type:
- property knots#
The knots of the univariate splines defining the spline surface.
- Returns:
The knots.
- Return type:
- property control_points#
The control points of the spline.
- Returns:
The control points.
- Return type: