Curve and Surface Fitting¶
New in version 5.0.
fitting
module provides functions for interpolating and approximating
Bspline curves and surfaces from data points. Approximation uses least
squares algorithm.
Please see the following functions for details:
Surface fitting generates control points grid defined in u and v
parametric dimensions. Therefore, the input requires number of data
points to be fitted in both parametric dimensions. In other words,
size_u
and size_v
arguments are used to fit curves of the
surface on the corresponding parametric dimension.
Degree of the output spline geometry is important to determine the
knot vector(s), compute the basis functions and build the coefficient
matrix, . Most of the time, fitting to a quadratic (degree = 2
)
or a cubic (degree = 3
) Bspline geometry should be good enough.
In the array structure, the data points on the vdirection come the first and udirection points come. The index of the data points can be found using the following formula:
Function Reference¶

geomdl.fitting.
interpolate_curve
(points, degree, **kwargs)¶ Curve interpolation through the data points.
Please refer to Algorithm A9.1 on The NURBS Book (2nd Edition), pp.369370 for details.
 Keyword Arguments:
centripetal
: activates centripetal parametrization method. Default: False
Parameters:  points (list, tuple) – data points
 degree (int) – degree of the output parametric curve
Returns: interpolated BSpline curve
Return type:

geomdl.fitting.
interpolate_surface
(points, size_u, size_v, degree_u, degree_v, **kwargs)¶ Surface interpolation through the data points.
Please refer to the Algorithm A9.4 on The NURBS Book (2nd Edition), pp.380 for details.
 Keyword Arguments:
centripetal
: activates centripetal parametrization method. Default: False
Parameters:  points (list, tuple) – data points
 size_u (int) – number of data points on the udirection
 size_v (int) – number of data points on the vdirection
 degree_u (int) – degree of the output surface for the udirection
 degree_v (int) – degree of the output surface for the vdirection
Returns: interpolated BSpline surface
Return type:

geomdl.fitting.
approximate_curve
(points, degree, **kwargs)¶ Curve approximation using least squares method with fixed number of control points.
Please refer to The NURBS Book (2nd Edition), pp.410413 for details.
 Keyword Arguments:
centripetal
: activates centripetal parametrization method. Default: Falsectrlpts_size
: number of control points. Default: len(points)  1
Parameters:  points (list, tuple) – data points
 degree (int) – degree of the output parametric curve
Returns: approximated BSpline curve
Return type:

geomdl.fitting.
approximate_surface
(points, size_u, size_v, degree_u, degree_v, **kwargs)¶ Surface approximation using least squares method with fixed number of control points.
This algorithm interpolates the corner control points and approximates the remaining control points. Please refer to Algorithm A9.7 of The NURBS Book (2nd Edition), pp.422423 for details.
 Keyword Arguments:
centripetal
: activates centripetal parametrization method. Default: Falsectrlpts_size_u
: number of control points on the udirection. Default: size_u  1ctrlpts_size_v
: number of control points on the vdirection. Default: size_v  1
Parameters:  points (list, tuple) – data points
 size_u (int) – number of data points on the udirection,
 size_v (int) – number of data points on the vdirection,
 degree_u (int) – degree of the output surface for the udirection
 degree_v (int) – degree of the output surface for the vdirection
Returns: approximated BSpline surface
Return type: