#include #include #include #include #include #define MAXPTS 50 #define MAXM 100 #define EPS 0.000001 #define STEP 0.001 #define ANALYTIC 1 #define DEBOOR 2 int mousex, mousey; int sirka=640, vyska=480; int pts=0; double P[MAXPTS][3]; int sel_pt=-1; double W[MAXPTS],T[MAXM],Tdisp[MAXM][2]; int col,i,D=3,POPISKY=0,MODE; double N[MAXM][MAXM], alpha[MAXM][MAXM], V[MAXM][MAXM][2], w[MAXM][MAXM]; void PisBitmapovyText(int x, int y, char *string, void *font) { int len, i; glRasterPos2f(x, y); len = (int) strlen(string); for (i = 0; i < len; i++) glutBitmapCharacter(font, string[i]); } int RatajAnalytic(double t, double *x, double *y){ int i,k; double cit,men; for (i=0;i=T[i]) && (tEPS) N[i][k] += N[i][k-1] * ( (t-T[i]) / (T[i+k]-T[i]) ); if (T[i+k+1]-T[i+1]>EPS) N[i][k] += N[i+1][k-1] * ( (T[i+k+1]-t) / (T[i+k+1]-T[i+1]) ); } cit=men=0.0; for (i=0;i1) && (T[pts]>T[D])) { glColor3d(1.0, 1.0, 0.0); glBegin(GL_LINE_STRIP); for (t=T[D];t<=T[pts];t+=STEP*(T[pts]-T[D])) { switch (MODE) { case ANALYTIC: ok=RatajAnalytic(t,&x,&y); break; case DEBOOR: ok=RatajDeBoor(t,&x,&y); break; } if (ok) { if ((col+MODE)%2) glColor3d(1.0,1.0,0.0); else glColor3d(1.0,0.33,0.0); glVertex3d(x,y,0.0); } } glEnd(); } // // RIADIACE BODY // glPointSize(10); glColor3d(0.6, 0.0, 0.0); glBegin(GL_POINTS); for (i=0;i1)) { D--; glutPostRedisplay(); } if ((key == '+') && (D-1) { P[sel_pt][0]=x; P[sel_pt][1]=y; } if (sel_pt<-1) { p=-(sel_pt+2); // hybeme knotbodom p newt=T[0] + (T[pts+D]-T[0])*(x-10.0)/(sirka-70.0); if (newtT[p+1]) newt=T[p+1]; T[p]=newt; } mousex = x; mousey = y; glutPostRedisplay(); } void mouse(int b, int s, int x, int y) { int i,j,ok; double add; mousex = x; mousey = y; if (b==GLUT_LEFT_BUTTON){ if (s==GLUT_DOWN) { ok=1; for (i=0;i