Curve and Surface Fitting¶
New in version 5.0.
fitting
module provides functions for interpolating and approximating
B-spline 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
) B-spline geometry should be good enough.
In the array structure, the data points on the v-direction come the first and u-direction 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.369-370 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 B-Spline 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 u-direction
- size_v (int) – number of data points on the v-direction
- degree_u (int) – degree of the output surface for the u-direction
- degree_v (int) – degree of the output surface for the v-direction
Returns: interpolated B-Spline 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.410-413 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 B-Spline 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.422-423 for details.
- Keyword Arguments:
centripetal
: activates centripetal parametrization method. Default: Falsectrlpts_size_u
: number of control points on the u-direction. Default: size_u - 1ctrlpts_size_v
: number of control points on the v-direction. Default: size_v - 1
Parameters: - points (list, tuple) – data points
- size_u (int) – number of data points on the u-direction,
- size_v (int) – number of data points on the v-direction,
- degree_u (int) – degree of the output surface for the u-direction
- degree_v (int) – degree of the output surface for the v-direction
Returns: approximated B-Spline surface
Return type: