#include #include #include #include #include #include #include #include Display *dis; Window win; XEvent report; GC green_gc; XColor green_col; Colormap colormap; char green[] = "#00FF00"; void rect() { //XDrawRectangle(dis, win, green_gc, 1, 1, 497, 497); //XDrawRectangle(dis, win, green_gc, 50, 50, 398, 398); XFlush(dis); } double f(double x) { static double phi=(1+sqrt(5.0))/2; // -2cos(4pi/5) if(0) return x*x; if(0) return x<0?0:-x; // périodique de période 7 if(0) return x<0?0:x; // périodique de période 5 if(0) return x*(1+x); if(0) return x*(1+x)/2-1; // (0,1) de période 4 if(0) return x*(x/1000-1); // diverge if(0) return x/(x-1); // 3 courbes if(0) return x*(x*x*x/9999-phi); // coquillage if(0) return x*(x*x*x*x*x/999+2*cos(M_PI*2/7)); // coquillage if(0) return 2*cos(M_PI*2/5)*x/(1-x*x*x); // 5 pétales if(0) return 2*cos(M_PI*2/7)*x/(1-x*x*x*x*x); // 7 pétales if(0) return (x>0?x*x:0)-x; // 13 boucles if(0) return x*(x-1)/2; // (0,1) -> courbe d'indice 2 avec 7 trous if(0) return x*(x-1)/3; if(0) return x*(2*x-1)/4; if(0) return x*(x+1)/2; // (0,1) -> de période 5, entouré d'anneaux qui se permutent (0,0.773291) -> courbe d'indice 2 if(0) return x*(1-x*x)/6; // (0,1) -> 2 courbes avec 4 trous if(0) return 1/(1+x*x); if(0) return 1/(1+x*x)-1; if(1) return x/(1+x*x); } int coord(double x) { return (x+2)/4*500; } // [-2..2] -> [0..500] double xini=0, yini=0, dx=0.05; void nuage() { int i,j; long double x=xini, y=xini, z; for(i=100000;i--;) { for(j=1;j--;) z=f(y)-x, x=y, y=z; XDrawPoint(dis, win, green_gc, coord(x), coord(y)); // http://www.cuis.edu/doc_vms_html/000000/731final/5642/5642pro_007.html } } int main() { dis = XOpenDisplay(NULL); win = XCreateSimpleWindow(dis, RootWindow(dis, 0), 1, 1, 500, 500, 0, BlackPixel (dis, 0), BlackPixel(dis, 0)); XMapWindow(dis, win); colormap = DefaultColormap(dis, 0); green_gc = XCreateGC(dis, win, 0, 0); XParseColor(dis, colormap, green, &green_col); XAllocColor(dis, colormap, &green_col); XSetForeground(dis, green_gc, green_col.pixel); XSelectInput(dis, win, ExposureMask | KeyPressMask | ButtonPressMask); nuage(); rect(); for(;;) { XNextEvent(dis, &report); switch(report.type) { case Expose: nuage(),rect(); break; case KeyPress: switch(XLookupKeysym(&report.xkey, 0)) { case 'q': exit(0); case 'p': xini+=dx; break; case 'm': xini-=dx; break; case 'h': dx/=2; break; case 't': dx*=2; break; case 'd': nuage(); break; case 'r': printf("x=%lf x=",xini),scanf("%lf",&xini); break; case 'w': printf("x=%lf \n",xini); break; } } } return 0; }