home *** CD-ROM | disk | FTP | other *** search
- //
-
- //+----------------------------------------------------------------------+
-
- //+ Program DISKS.CPP +
-
- //+ By Fausto A. A. Barbuto, BJ06@C53000.PETROBRAS.ANRJ.BR +
-
- //+ Rio de Janeiro, BRAZIL, on May 14, 1994. +
-
- //+ +
-
- //+ Plots six Julia sets with inner contours in shadings of gray. +
-
- //+ +
-
- //+ REFERENCE: Peitgen, H.-O. & Richter, P.H.: "The Beauty of Fractals", +
-
- //+ Springer-Verlag, 1986. +
-
- //+ +
-
- //+ Needs SVGA256.BGI and SVGA256.H (from SVGABG50 package by Jordan +
-
- //+ Hargrave). +
-
- //+ +
-
- //+ Authorized version for spanky.triumf.ca site (Vancouver, BC, CANADA).+
-
- //+----------------------------------------------------------------------+
-
- //
-
- #include <stdio.h>
-
- #include <conio.h>
-
- #include <graphics.h>
-
- #include <math.h>
-
- #include "Svga256.h"
-
- //void far initgraph(int far *,int far *,char far *);
-
-
-
- int Vid; //Global variable
-
-
-
- int huge DetectSVGA256()
-
- {
-
- printf("\n Which video mode would you like to use? \n\n");
-
- printf(" 0 - 320x200x256\n");
-
- printf(" 1 - 640x400x256\n");
-
- printf(" 2 - 640x480x256\n");
-
- printf(" 3 - 800x600x256\n");
-
- printf(" 4 - 1024x768x256\n\n");
-
- printf(" (Try mode 4, if possible) \n\n > ");
-
- scanf("%d",&Vid);
-
- return Vid;
-
- }
-
-
-
- void main(void)
-
- {
-
- double xmin, xmax, ymin, ymax, x, y, x0, y0, R1, I1, Temp;
-
- double deltax, deltay, p, q, r, a, b;
-
- double c1[6] = {15.0,18.0,15.0,15.0,18.0,15.0};
-
- double c2[6] = {1.25e+7,13.0,1.5e+3,38.0,125.0,75.0};
-
- register int npix, npiy, k, np, nq;
-
- int Maxit, ipen, index;
-
- int graphdriver=DETECT, graphmode;
-
-
-
- printf("\n Program DISKS.CPP \n");
-
- printf("\n\n By Fausto A. A. Barbuto, May 14, 1994");
-
- printf("\n Rio de Janeiro, Federal Republic of Brazil");
-
- printf("\n E-mail: BJ06@C53000.PETROBRAS.ANRJ.BR\n\n");
-
- printf("\n Reference: Peitgen, H.-O., and Richter, P.H. :");
-
- printf("\n 'The Beauty of Fractals', Springer-Verlag, 1986\n\n");
-
- printf("\n Select a Julia set: \n\n");
-
- printf(" 1: c = -0.123750 + 0.565080i (Map 20, pg. 52) \n");
-
- printf(" 2: c = -0.390540 - 0.586790i (Map 22 & 25, pgs. 52, 77)\n");
-
- printf(" 3: c = 0.310000 + 0.040000i (Hmmm... Pretty good!)\n");
-
- printf(" 4: c = -0.481762 - 0.531657i \n");
-
- printf(" 5: c = 0.273340 + 0.007420i (Fausto's favourite)\n");
-
- printf(" 6: c = -0.125000 + 0.649250i \n");
-
- printf("\n> ");
-
- scanf("%d",&index);
-
- if ((index<1) || (index>6)) index = 1;
-
-
-
- if (index == 1) {xmin=-1.40;xmax=1.40;ymin=-1.4;ymax=1.4;Maxit=128;
-
- p=-0.123750;q= 0.565080;}
-
- if (index == 2) {xmin=-1.50;xmax=1.50;ymin=-1.5;ymax=1.5;Maxit=256;
-
- p=-0.390540;q=-0.586579;}
-
- if (index == 3) {xmin=-1.20;xmax=1.20;ymin=-1.2;ymax=1.2;Maxit=256;
-
- p= 0.310000;q= 0.040000;}
-
- if (index == 4) {xmin=-1.50;xmax=1.50;ymin=-1.5;ymax=1.5;Maxit=512;
-
- p=-0.481762;q=-0.531657;}
-
- if (index == 5) {xmin=-1.10;xmax=1.10;ymin=-1.1;ymax=1.1;Maxit=256;
-
- p= 0.273340;q= 0.007420;}
-
- if (index == 6) {xmin=-1.75;xmax=1.75;ymin=-1.5;ymax=1.5;Maxit=512;
-
- p=-0.125000;q= 0.649250;}
-
- clrscr();
-
-
-
- installuserdriver("Svga256",DetectSVGA256);
-
- initgraph(&graphdriver, &graphmode, "c:\\borlandc\\bgi");
-
- if (Vid == 0) {npix = 320; npiy = 200;}
-
- if (Vid == 1) {npix = 640; npiy = 400;}
-
- if (Vid == 2) {npix = 640; npiy = 480;}
-
- if (Vid == 3) {npix = 800; npiy = 600;}
-
- if (Vid == 4) {npix =1024; npiy = 768;}
-
- if((Vid<0) || (Vid)>4) Vid = 2;
-
-
-
- deltax = (xmax-xmin)/(npix-1);
-
- deltay = (ymax-ymin)/(npiy-1);
-
-
-
- cleardevice();
-
- for (np=0; np<=npix-1; np++) {
-
- x0 = xmin + (double)np*deltax;
-
- for (nq=0; nq<=npiy-1; nq++) {
-
- y0 = ymin + (double)nq*deltay;
-
- x = x0;
-
- y = y0;
-
- k = 0;
-
-
-
- do {
-
- Temp = x*y;
-
- R1 = (x-y)*(x+y) + p;
-
- I1 = Temp + Temp + q;
-
- r = sqrt(R1*R1 + I1*I1);
-
- k++;
-
-
-
- if (r >= Maxit) { //* Escaped points. *//
-
- ipen = 30 + k;
-
- putpixel(np,nq,ipen);
-
- }
-
-
-
- if (k == Maxit) { //* Converged points. *//
-
- //*
-
- //* The colour shades of the inner contours are defined here
-
- //* (as function of the distance between the current point [x,y]
-
- //* and an "invariant" point [x=R(z),y=I(z)]).
-
- //*
-
- a = (x-R1)*(x-R1);
-
- b = (y-I1)*(y-I1);
-
- ipen = c1[index-1] + (int)(c2[index-1]*sqrt(a+b));
-
- putpixel(np,nq,ipen);
-
- }
-
-
-
- x = R1;
-
- y = I1;
-
- } while (r <= Maxit && k<=Maxit);
-
- }
-
- if(kbhit()) break;
-
- }
-
-
-
- getch();
-
- closegraph();
-
- }
-
-