Prashant,
If N is the number of control points for a spline curve
and D is the degree (D = p+1, where p is the order of the polynomials
that define the spline functions),
and K is the number of knots (knot values, defining the range of the
parameter over which the spline is defined), then
K = N+D
Note that this is differs from the relation given in the ISO/IEC FDIS
19775-1:2008 standard, Sec 27.2.3 (see
http://www.web3d.org/x3d/specifications/ISO-IEC-FDIS-19775-1.2-X3D-
AbstractSpecification/Part01/components/
nurbs.html#CommonGeometryFieldsAndCorrectness)
By my calculations, the relation I have given above is correct* and
moreover it works with OpenGL.
For most applications, the first D knots are equal to the lowest value
of the parameter, and the last D values are equal to
the highest value of the parameter, the interior knots (if any) may or
may not be equally spaced, but do need to be ordered. For your case,
with D=3 and N=5 we need K=8 knot values, for the parameter u from 0 to
1 a valid, equally spaced set of knots is:
knots = [0.0,0.0,0.0, 0.33, 0.66, 1.0,1.0,1.0]
*If you look at the calculations to evaluate the splines you will find
that the first and last knot values are
extraneous. However, every API or standard I have examined for NURBS
(OpenGL, ISO 10303, "The NURBS Book"...) requires that
they be included in the knots vector, and the relation I give above is
the one required by the software I have used.
Regards,
Vince Marchetti
|