grains.cad.fit_spline¶
-
grains.cad.fit_spline(points, degree_min=3, degree_max=8, continuity='C2', tol=0.001)[source]¶ Approximates a set of points on the plane with a B-spline.
- Parameters
points (ndarray) – 2D ndarray with N>=2 rows and 2 columns, representing the points on the plane, ordered from one end point to the other. The first column gives the x, the second column gives the the y coordinates of the points.
degree_min (int, optional) – Minimum degree of the spline. The default is 3.
degree_max (int, optional) – Maximum degree of the spline. The default is 8.
continuity ({‘C0’, ‘G1’, ‘C1’, ‘G2’, ‘C2’, ‘C3’, ‘CN’}, optional) – The continuity of the spline will be at least continuity. The default is ‘C2’. For their meanings, consult with https://www.opencascade.com/doc/occt-7.4.0/refman/html/_geom_abs___shape_8hxx.html
tol (float, optional) – The distance from the points to the spline will be lower than tol. The default is 1e-3.
- Returns
spline (Geom_BSplineCurve) – For details on the resulting spline, see the OpenCASCADE documentation: https://www.opencascade.com/doc/occt-7.4.0/refman/html/class_geom___b_spline_curve.html
- Raises
ValueError – If the minimum degree of the B-spline to be constructed is greater than its maximum degree.