It is known that circles and spheres can be represented exactly by NURBS curve and surface respectively. I confirmed that this works correctly using the algorithm of NURBS. But, I could not obtain the correct results using the NURBS functions of OpenGL. I cannot understand why. Attached below is the image comparing the correct result and wrong result created by the OpenGL NURBS function.
The following is the OpenGL code.
void _OpenGLDrawCircleByNURBS(void)
{
GLfloat pXyz[9][4]={ 1.0, 0.0, 0.0, 1.0,
1.0, 1.0, 0.0, 0.707107,
0.0, 1.0, 0.0, 1.0,
-1.0, 1.0, 0.0, 0.707107,
-1.0, 0.0, 0.0, 1.0,
-1.0,-1.0, 0.0, 0.707107,
0.0,-1.0, 0.0, 1.0,
1.0,-1.0, 0.0, 0.707107,
1.0, 0.0, 0.0, 1.0};
GLfloat uKnotVect[]={0.0, 0.0, 0.0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1.0, 1.0, 1.0};
GLUnurbsObj *theNurb;
theNurb=gluNewNurbsRenderer();
gluNurbsProperty(theNurb,GLU_SAMPLING_TOLERANCE,25.0);
gluNurbsProperty(theNurb,GLU_DISPLAY_MODE,GLU_OUTLINE_PATCH);
gluBeginCurve(theNurb);
gluNurbsCurve(theNurb,
12,uKnotVect,
4,
&pXyz[0][0],
3,
GL_MAP1_VERTEX_4);
gluEndCurve(theNurb);
}