#include #include #include #include #include #define MAXPTS 200 #define EPS 0.000001 typedef struct { double c[205]; int deg; } tPoly; int mousex, mousey; int sirka=640, vyska=480; int pts=0; double P[205][3]; int sel_pt=-1; tPoly Poly; void bitmap_output(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 ComputePoly(void){ tPoly P1,P2; int robim,uz,nasob,i; double pow,val; if (pts==0) return; if (pts==1) { Poly.deg=0; Poly.c[0]=P[0][1]; return; } uz=0; Poly.deg=0; Poly.c[0]=0; for (robim=0;robimPoly.deg) Poly.deg=P1.deg; } } } double EvalPoly(double kde){ double pow,val; int i; pow=1.0; val=0.0; for (i=0;i<=Poly.deg;i++) { val+=pow*Poly.c[i]; pow*=kde; } return val; } void display(void) { char msg[1000]; double p1[3],p2[3]; int i,j; glClear(GL_COLOR_BUFFER_BIT); glColor3f(1, 0, 0); // if (pts>0) for (i=Poly.deg;i>=0;i--) { // sprintf(msg,"%.3f x^%d",Poly.c[i],i); // bitmap_output(20, 20*(i+1), msg,GLUT_BITMAP_TIMES_ROMAN_24); // } // sprintf(msg,"[%d %d] pts=%d",mousex,mousey,pts); // bitmap_output(40, 35, msg,GLUT_BITMAP_TIMES_ROMAN_24); ComputePoly(); if (pts>0) for (i=0;i