Path: csus.edu!wuarchive!julius.cs.uiuc.edu!news.cs.indiana.edu!iuvax!copper!blank From: blank@copper.ucs.indiana.edu (doug blank) Newsgroups: alt.fractals.pictures Subject: Fractal Pictures Message-ID: <76832@iuvax.cs.indiana.edu> Date: 6 Dec 90 18:00:20 GMT References: <28420@usc> Sender: news@iuvax.cs.indiana.edu Distribution: ca Organization: Indiana University, Bloomington IN. Lines: 192 We just picked up this newsgroup here at Indiana U, and its interesting to see so many exploring the world of fractals. I was a bit (maybe even a byte) confusued though to see that these were the actual postings of the pictures. Wouldn't it save much time and space to just send the coordinates or magnification of the beautiful spots and let each generate? Maybe some would take awhile on a pc, but at a 1200 baud download, which is faster? Here are two files which allow the generation and display of spots in the Mandelbrot set. They are divided into two programs so that you could generate them on the fastest computer you have access to, and then display them on a pc. The display program is set up for four colors at present. The gif, gem, etc, formats are probably much more complicated, but if you could list the coordinates or magnification when you find a spectaular place in the Mandelbrot set, some of us could generate it. Maybe others have written code that generates other formats (gem, gif) and would be willing to share. -doug blank blank@iuvax.cs.indiana.edu p.s. - I have heard rumours that the phrase "Paul is dead" can be found somewhere in the Mandelbrot set. ----------------------------------------------- /* File generate.c */ /* By Jim Marshall and Doug Blank */ /* B-row by A-column pixel matrix is stored as a linear file of ASCII characters in top-down row-major order. Thus, the first A characters correspond to the top row of the screen, the next A characters correspond to the row 2nd from the top, and so on. Each matrix entry stores the number of iterations required for the entry's associated complex number to escape to infinity, or zero if the number falls within the Mandelbrot Set. A number N is stored in the file as an ASCII char- acter of code N. */ #include char mode; char filename[15]; int A,B,MAXK,np,nq,k; double p,q,pmin,pmax,qmin,qmax,deltap,deltaq,pside,qside,padjust,qadjust; double M,METRIC,R,r,ratio,mag,x,y,xnext,ynext; FILE *fopen(),*fp; main() { A = 320; /* horizontal screen resolution (pixels) */ B = 200; /* vertical screen resolution (pixels) */ R = 0.7; /* ratio of screen height to screen width */ METRIC = 3.0; /* imaginary range size at magnification = 1.0 */ MAXK = 200; /* maximum number of iterations to perform at each point */ M = 100.0; printf("\nSpecify window using coordinates or magnification? (c/m): "); scanf("%c",&mode); if (mode == 'm') { printf("Enter central coordinate (real, imaginary): "); scanf("%f %f",&p,&q); printf("Enter magnification factor: "); scanf("%f",&mag); qadjust = METRIC/(2.0*mag); padjust = qadjust/R; pmin = p - padjust; pmax = p + padjust; qmin = q - qadjust; qmax = q + qadjust; } else { printf("Enter real minimum, maximum values: "); scanf("%f %f",&pmin,&pmax); printf("Enter imaginary minimum, maximum values: "); scanf("%f %f",&qmin,&qmax); pside = pmax - pmin; qside = qmax - qmin; ratio = qside/pside; if (ratio < R) { qadjust = (R*pside - qside)/2.0; qmin = qmin - qadjust; qmax = qmax + qadjust; } if (ratio > R) { padjust = (qside/R - pside)/2.0; pmin = pmin - padjust; pmax = pmax + padjust; } } printf("Real range scaled to: %g to %g\n",pmin,pmax); printf("Imaginary range scaled to: %g to %g\n",qmin,qmax); printf("Enter name of output file: "); scanf("%s",filename); deltap = (pmax - pmin)/(A - 1); deltaq = (qmax - qmin)/(B - 1); fp = fopen(filename,"w"); for (nq = 0; nq < B; ++nq) { for (np = 0; np < A; ++np) { p = pmin + (np * deltap); q = qmax - (nq * deltaq); x = 0.0; y = 0.0; k = 0; do { /* iterate critical point (x,y) = (0,0) with parameter (p,q) */ xnext = x*x - y*y + p; ynext = 2.0*x*y + q; x = xnext; y = ynext; ++k; r = x*x + y*y; } while ((r <= M) && (k < MAXK)); if (r > M) putc(k+32,fp); else putc(0,fp); } } fclose(fp); } /* EOF of fract.c */ --------------------------------------------------------- /* File display.c */ /* Written by Jim Marshall and Doug Blank */ #include #include #include int A, B, np, nq, k, color; void keyboard (void); main () { A = 640; /* horizontal screen resolution (pixels) */ B = 350; /* vertical screen resolution (pixels) */ _setvideomode (_ERESCOLOR); for (nq = 0; nq < B; ++nq) { for (np = 0; np < A; ++np) { scanf ("%c", &k); if (k == 32) color = 0; else color = ((k - 32) % 4) + 1; _setcolor (color); _setpixel (np, nq); } } keyboard (); _clearscreen (_GCLEARSCREEN); _setvideomode (_DEFAULTMODE); exit (0); } void keyboard (void) { union u_type { int a; char b[3]; } keystroke; int get_keystroke (void); do keystroke.a = get_keystroke (); while (keystroke.b[0] != 27); } int get_keystroke (void) { union REGS regs; regs.h.ah = 0; return int86 (0x16, ®s, ®s); } ===================================================================== blank@iuvax.cs.indiana.edu Douglas Blank, Indiana University --------------------------------------------------------------------- Computer Science Cognitive Science