#include #include #include #include #include #define MAXPTS 200 #define EPS 0.000001 #define STEP 0.01 #define CARDINAL 1 #define BETA 2 int mousex, mousey; int sirka=640, vyska=480; int pts=0,mode=CARDINAL; double ALPHA=0.7,BETA1=0.3,BETA2=0.0; double P[205][3]; int sel_pt=-1,color=0; double M[4][4]; int is_ctrl,is_alt,is_shift; 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]); } void DrawSplineSegment(double x0, double y0, double x1, double y1, double x2, double y2, double x3, double y3) { int i,j; double P1[4],V1[4],P2[4],V2[4]; double t,x,y,pom; V1[0]=x0; V1[1]=x1; V1[2]=x2; V1[3]=x3; for (i=0;i<4;i++) { P1[i]=0; for (j=0;j<4;j++) P1[i]+=M[i][j]*V1[j]; } V2[0]=y0; V2[1]=y1; V2[2]=y2; V2[3]=y3; for (i=0;i<4;i++) { P2[i]=0; for (j=0;j<4;j++) P2[i]+=M[i][j]*V2[j]; } if (color) glColor3d(1.0,1.0,0.0); else glColor3d(1.0,0.33,0.0); color=!color; glBegin(GL_LINE_STRIP); for (t=0.0;t<1.0+STEP-EPS;t+=STEP) { x=0; pom=1.0; for (i=3;i>=0;i--) { x+=pom*P1[i]; pom*=t; } y=0; pom=1.0; for (i=3;i>=0;i--) { y+=pom*P2[i]; pom*=t; } glVertex2d(x,y); } glEnd(); } void display(void) { int i,j; char pom[100]; glClear(GL_COLOR_BUFFER_BIT); glColor3d(0.3, 0.3, 0.3); glBegin(GL_LINE_STRIP); for (i=0;i=4) { DrawSplineSegment(P[0][0],P[0][1],P[0][0],P[0][1],P[1][0],P[1][1],P[2][0],P[2][1]); for (i=0;i+3