I've been working on an OpenGL project that's essentially practice for drawing b-spline curves. My program returns no errors but the curves won't display.
Given an array of control points of length 13 named 'coords' (the control points themselves are all visible on-screen), this is my code:
glBegin(GL_LINE_STRIP);
float x=0;
float y=0;
float z=0;
for (double u = 3; u <= 14; u+=0.1){
for (int i = 1; i <=13; i++){
x += NofU(u,i)*coords[i].x;
y += NofU(u,i)*coords[i].y;
z += NofU(u,i)*coords[i].z;
}//for
}//for
glVertex3f(x, y, z);
glEnd();
Where "NofU" represents the blending functions:
double NofU(double u, int i){
if (u < i)
return 0;
else if (u < i+1)
return (1/6)*pow(u,3);
else if (u < i+2)
return (1/6)*((-3)*pow(u,3)+3*pow(u,2)+3*u+1);
else if (u < i+3)
return (1/6)*(3*pow(u,3)-6*pow(u,2)+4);
else if (u < i+4)
return (1/6)*pow((1-u),3);
else
return 0;
}//NofU
When I attempt print statements, I end up with either insanely large or small coordinate values, or just 0.