View Full Version : nurbs curves

01-14-2002, 09:41 AM
i have a stupid problem. it is so stupid that i believe there exists a hardware problem or so http://www.opengl.org/discussion_boards/ubb/smile.gif

i am trying to draw a simple nurbs curve (it is not even surface!) with 9 points. however everything is ok upto 8 points, but when i try to extend it to 9, nothing is drawn... real stupid isn't it? i don't think there is a limit for that, however i cannot figure out what the problem is..

by the way, i am coding with Qt on RH Linux 7.2 and i have pII-350 with 16 MB nvidia Vanta processor.

Rob The Bloke
01-14-2002, 11:23 AM
Hmmmmmmm, a bug in hardware you say? I disagree with ya strongly on that one (I know for a fact that no commercially available graphics card actually supports evaluators in hardware).

I put money on the fact that you haven't changed the knot vector when you added a CV. You may notice that the number of CV's isn't actually specified as a parameter in any of the gluNurbs functions :

void gluNurbsCurve (GLUnurbsObj *nobj, GLint uknot_count,
GLfloat *uknot, GLint u_stride, GLfloat *ctlarray,
GLint uorder, GLenum type);

The number of CV's is actually determined by the knot counts and the curve order. For example a simple cubic bezier described as a uniform B-spline would have a degree of 3 (order 4), 4 control points and a knot vector of :

0 0 0 0 1 1 1 1

if you want to add an extra control point in you would use a knot vector of :

0 0 0 0 1 2 2 2 2

so now you have 9 knot values, still a degree of 3 (order 4) and five control points.

You could follow the rule detailed above by saying

NumKnots = NumCVs + CurveOrder

whilst this would work for all uniform clamped curves it's not a rule of thumb and there are situations such as periodic or unclamped curves where it goes flying out the window.

I'd recommend reading up on the maths behind Nurbs a bit more, it will help a lot when dealing with NURBS curves and surfaces. . .

[This message has been edited by Rob The Bloke (edited 01-14-2002).]

01-14-2002, 11:04 PM
so you lost some money http://www.opengl.org/discussion_boards/ubb/smile.gif. i am updating my knot vector, however. you are right. i don't know much about knot vectors. i have read some about nurbs, but none of them contain a clear description on the knots. do you know such a text? i prefer onine ones, because it is not so easy for me to obtain printed ones.

the confusing part is that: the same thing happens when i am using cubic beziers. here what i am trying to draw:

i define nine points that forms a straight line:

GLfloat point[9][3]={{0,0,0},{40,40,0},{80,80,0},{120,120,0},{160,160 ,0},{200,200,0},{240,240,0},{280,280,0},{320,320,0 }};

and evaluation the curve as:


so simple isn't it? the code should produce a straight line from (0,0) to (320,320). when i am using the number of points up to 8, the result is perfect (beginning from any point), however when this number reaches to 9, nothing is drawn.. so stupid isn't it?

and the nurbs one:

my knot vector is


using the same points, i evaluate the simple nurbs curve as:

gluNurbsCurve(pnurb , 18 , knot, 3 ,&point[0][0],9);

i don't know if this kind of knot vector is correct, i found the logic by trial error, beginning from the 4 point curve.. i am putting first n elements on the knot vector as zero and the second n as 1.0 and using the vector size as 2n where n is the number of points. it is again worked well upto 8 points, and failed at the 9th!!!! i also tried to use smaller knots of the same form, but it also did't worked..

i am agree and perfectly sure that this shouldn't be a hardware bug, but what is it then? let's say i am misusing the knots concept, but beziers must draw at least a straight line...

thank you for your help. I have the same code that is written years ago using PHIGS, that evaluates nurbs by code.. i thought i won't be have to add the same code to the OpenGL version.. but it seems i should do that http://www.opengl.org/discussion_boards/ubb/smile.gif.

have a nice day. your help is really appreciated.