/* trigplot.c by Eric R. Weeks http://chaos.ph.utexas.edu/~weeks/ weeks@chaos.ph.utexas.edu This program is public domain, but please leave my name on it; if you modify it at all, leave comments in this header saying that you've modified it. tabstop = 5 NOTE:::: **** due to the requirements of PPM output, the internal **** variables X,Y are swapped on the screen! trigplot: v01: 8-07-96: taken from mesh4.c v02: 8-08-96: added in -ijkl options v03: 8-22-96: cleaned up a little bit to compile: gcc -o tplot trigplot3.c -lm */ #include #include #include #define PI 3.14159265358979323846264338328 #define EE 2.71828182845904523536 #define MAX 2000 void hcolor(); int hxres,hyres; int col[3][256]; double magnify; float aaa,bbb,ccc,ddd,eee,fff,iii,jjj,kkk,lll; float sinx[MAX],cosx[MAX]; float siny[MAX],cosy[MAX]; main(int argc,char **argv) { int c,atoi(); double atof(); extern int optind; extern char *optarg; int t,r; double x; int hx,hy; /* ----- Initialize variables ----- */ hxres = 300; hyres = 300; magnify = 1.0; /* no magnification */ aaa = 1.0; bbb = 1.0; ccc = 1.0; ddd = 1.0; eee = 1.0; fff = 1.0; iii = 1.0; jjj = 1.0; kkk = 1.0; lll = 1.0; while ((c = getopt(argc, argv, "hn:x:y:vm:a:b:c:d:e:f:i:j:k:l:")) != EOF) switch (c) { case 'h': fprintf(stderr,"Usage: %s [options]\n",argv[0]); fprintf(stderr," -h : this help message\n"); fprintf(stderr," -x # : x resolution in pixels [%d]\n",hyres); fprintf(stderr," -y # : y resolution in pixels [%d]\n",hxres); fprintf(stderr," -m # : magnification factor [%.1f]\n",magnify); fprintf(stderr," -abcdef -ijkl # : set parameters in the eqn:\n"); fprintf(stderr," z = e sin(a sin(ix) + b cos(jy)) + f cos(c cos(kx) + d sin(ly))"); fprintf(stderr,"\n\n a %.1f b %.1f c %.1f d %.1f",aaa,bbb,ccc,ddd); fprintf(stderr," e %.1f f %.1f\n",eee,fff); fprintf(stderr,"\n i %.1f j %.1f k %.1f l %.1f\n",iii,jjj,kkk,lll); exit(1); break; case 'x': hyres = atoi(optarg); break; case 'y': hxres = atoi(optarg); break; case 'm': magnify = atof(optarg); break; case 'a': aaa = atof(optarg); break; case 'b': bbb = atof(optarg); break; case 'c': ccc = atof(optarg); break; case 'd': ddd = atof(optarg); break; case 'e': eee = atof(optarg); break; case 'f': fff = atof(optarg); break; case 'i': iii = atof(optarg); break; case 'j': jjj = atof(optarg); break; case 'k': kkk = atof(optarg); break; case 'l': lll = atof(optarg); break; } printf("P6\n# CREATOR: Eric R Weeks / trigplot3 program\n"); printf("%d %d\n255\n",hyres,hxres); for (t=0;t