1 .. |curvefitting.icon| image:: images/curvefitting.png
6 The Curve Fitting is a tool to create a curve by a set of given points.
8 To start this operation:
10 #. select *Sketch - > Curve fitting* item in the Main Menu or
11 #. click |curvefitting.icon| **Curve fitting** button in the Sketch toolbar:
13 There are 2 algorithms for the curve creation:
15 - **Interpolation** - the curve passes exactly through the selected points;
16 - **Approximation** - curve passes near the selected points to some extent.
18 Both algorithms have additional options:
20 - **Periodic** - forces the created curve to be smooth periodic curve;
21 - **Closed** - produces closed, but non-periodic curve. As a result, it has the same start and end points, but it may be connected non-smoothly there;
22 - **Create control polygon** - if the fitting curve is a B-spline curve, this option will create it's control polygon.
28 .. image:: images/curvefitting_panel_interpolation.png
31 Select the list of points to create a curve. The curve will pass directly through these points in the given order.
33 Clicking the **Reorder points** button will change the order of selected points to minimize the distances between the neighbors.
37 .. py:function:: Sketch_1.addInterpolation(points, periodic = False, closed = False)
39 :param list: points for the curve.
40 :param boolean: flag to make the curve periodic.
41 :param boolean: flag to make the curve closed but not periodic.
42 :return: interpolated curve.
47 The interpolated curve appears in the view.
49 .. image:: images/curvefitting_interpolation_res.png
53 Interpolation curve (non-closed, periodic and closed)
55 **See Also** a sample TUI Script of :ref:`tui_create_sketch_interpolation` operation.
61 .. image:: images/curvefitting_panel_approximation.png
64 Select the list of points to create a curve and set the **Precision** value. The curve will pass not far than the precision of these points.
66 Clicking the **Reorder points** button will change the order of selected points to minimize the distances between the neighbors.
70 .. py:function:: Sketch_1.addApproximation(points, precision = 0.001, periodic = False, closed = False)
72 :param list: points for the curve.
73 :param double: how close the curve should pass according to the points.
74 :param boolean: flag to make the curve periodic.
75 :param boolean: flag to make the curve closed but not periodic.
76 :return: interpolated curve.
81 The interpolated curve appears in the view.
83 .. image:: images/curvefitting_approximation_res.png
87 Approximated curve (non-closed, periodic and closed)
89 **See Also** a sample TUI Script of :ref:`tui_create_sketch_approximation` operation.