File:SeregaFunction03.png

Drawing of the trigonometric approximation of the Serega function

C++ generator of the curve

 * 1) include 
 * 2) include 
 * 3) include 
 * 4) define DB double
 * 5) define DO(x,y) for(x=0;x<y;x++)

void ado(FILE *O, int X, int Y) {      fprintf(O,"%c!PS-Adobe-2.0 EPSF-2.0\n",'%'); fprintf(O,"%c%cBoundingBox: 0 0 %d %d\n",'%','%',X,Y); fprintf(O,"/M {moveto} bind def\n"); fprintf(O,"/L {lineto} bind def\n"); fprintf(O,"/S {stroke} bind def\n"); fprintf(O,"/s {show newpath} bind def\n"); fprintf(O,"/C {closepath} bind def\n"); fprintf(O,"/F {fill} bind def\n"); fprintf(O,"/times-Roman findfont 20 scalefont setfont\n"); fprintf(O,"/W {setlinewidth} bind def\n"); fprintf(O,"/RGB {setrgbcolor} bind def\n");}


 * 1) define M(x,y) fprintf(o,"%8.5f %8.5f M\n",0.+x,0.+y);
 * 2) define L(x,y) fprintf(o,"%8.5f %8.5f L\n",0.+x,0.+y);

main{ int n; DB x,y,t,c,s,z; FILE *o; o=fopen("03.eps","w"); ado(o,1204,208); fprintf(o,"602 101 translate 200 200 scale\n"); for(n=-6;n<7;n++) {M(n/2.,-.5)L(n/2.,.5)} for(n=-6;n<7;n++) {M(-3, n/2.)L(3,n/2.)} fprintf(o,".002 W S\n"); DO(n,1260){t=-3.04+.005*n; c=cos(t); s=sin(t); z=1.3-c; z*=z; x=-(t-s-.2/(1.2-c)); y=.2+.1*s+.85*c -.05/z-.003/z/z; y*=.75; if(n==0) M(x,y) else L(x,y) } fprintf(o,"1 setlinejoin .005 W 0 0 1 RGB S\n"); fprintf(o,"showpage\n%c%cTrailer",'%','%'); fclose(o); system("epstopdf 03.eps"); system(   "open 03.pdf"); //for macintosh getchar; system("killall Preview"); //for macintosh }