.. role:: blue :class: blue Constructing Two-Dimensional NURBS Curve ======================================== .. _Constructing_Two-Dimensional_NURBS_Curve_: .. kernel version: 118058 The function .. code-block:: cpp MbResultType NurbsCurve( const SArray & pointList, const SArray & weightList, size_t degree, const SArray & knotList, bool curveClosed, MbCurve *& result ); constructs a two-dimensional NURBS curve based on a specified set of control points. The input parameters of the function are: - **pointList** - the set of control points; - **weightList** - the set of control point weights; - **degree** - the order of the B-spline; - **knotList** - the set of parametric knots (knot vector); - **curveClosed** - the flag indicating periodic closure of the curve. The output parameter of the function is the constructed curve **result**. Upon successful completion, the function returns :blue:`rt_Success`; otherwise, it returns an error code from the :ref:`MbResultType ` enumeration. The function is declared in the file *action_curve.h*. The function constructs a NURBS curve (a curve based on *B*-splines), which is described in subsection :ref:`Two-Dimensional NURBS Curve MbNurbs `. The set of weights **weightList** must correspond in size to the set of control points **pointList**. The curve order **degree** must not exceed the number of control points. The parameter **curveClosed** determines the periodic closure of the constructed curve. The knot vector **knotList** represents a non-decreasing sequence of real numbers that defines the parameter domain and shape of the curve. For **curveClosed** = *false*, the knot vector must contain a number of elements equal to the number of control points plus the curve order. For **curveClosed** = *true*, the knot vector must contain a number of elements equal to the number of control points plus twice the curve order minus one. To make an open NURBS curve pass through end control points, the first **degree** elements of the knot vector **knotList** must be equal to each other, and the last **degree** elements of the knot vector **knotList** must also be equal to each other. Figure 1 shows a closed NURBS curve of the fourth order: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.1.png :width: 16cm :align: center Fig. 1 Figure 2 shows an open NURBS curve of the fourth order passing through the end control points: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.2.png :width: 16cm :align: center Fig. 2 Figure 3 shows three closed NURBS curves of different orders constructed from the same control points: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.3.png :width: 16cm :align: center Fig. 3 Figure 4 shows three open NURBS curves of different orders constructed from the same control points: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.4.png :width: 16cm :align: center Fig. 4 Figure 5 shows three open NURBS curves of the fourth order having different control point weights: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.5.png :width: 16cm :align: center Fig. 5 Figure 6 shows an open NURBS curve of the third order whose shape matches a circular arc. The distance between control points **pointList**\[0\] and **pointList**\[1\] equals the distance between control points **pointList**\[1\] and **pointList**\[2\], and the weight **weightList**\[1\] of the middle control point equals the weight of the end control points multiplied by the cosine of half the arc angle. .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.4.6.png :width: 12cm :align: center Fig. 6 The function .. code-block:: cpp MbResultType NurbsCopy( const MbCurve & curve, MbCurve *& result ); constructs a NURBS copy of a given two-dimensional curve. The input parameter of the function is the source curve **curve**. The output parameter of the function is the constructed curve **result**. The function constructs a NURBS curve whose shape copies that of the source curve. For most curve types, the NURBS copy exactly matches the source curve in shape. In cases where it is impossible to exactly reproduce the source curve's shape, the NURBS copy approximates the source curve. In the test application *test.exe*, construction of a two-dimensional NURBS curve is performed using the menu command "Create→Curve in space→By points→NURBS".