Constructing Two-Dimensional NURBS Curve

The function

MbResultType NurbsCurve( const SArray<MbCartPoint> & pointList,
                         const SArray<double> &      weightList,
                               size_t                degree,
                         const SArray<double> &      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 rt_Success; otherwise, it returns an error code from the 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 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:

../../../../_images/M.3.4.1.png

Fig. 1

Figure 2 shows an open NURBS curve of the fourth order passing through the end control points:

../../../../_images/M.3.4.2.png

Fig. 2

Figure 3 shows three closed NURBS curves of different orders constructed from the same control points:

../../../../_images/M.3.4.3.png

Fig. 3

Figure 4 shows three open NURBS curves of different orders constructed from the same control points:

../../../../_images/M.3.4.4.png

Fig. 4

Figure 5 shows three open NURBS curves of the fourth order having different control point weights:

../../../../_images/M.3.4.5.png

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.

../../../../_images/M.3.4.6.png

Fig. 6

The function

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”.