Color shows in which quadrant of a Cartesian coordinate system n-th iteration lands:
re(z_n) > 0 and im(z_n) > 0 (first quadrant)
re(z_n) < 0 and im(z_n) > 0 (second)
re(z_n) < 0 and im(z_n) < 0 (third)
re(z_n) > 0 and im(z_n) < 0 (fourth).
Because there are 4 quadrants then 4 colors are used .
"... when the four colors are meeting somewhere, you have a zero of q_n(c), i.e., a center of [hyperbolic component for] period dividing n. In addition, the light or dark color shows if c is in M." ( Wolf Jung )
/* c console program:---------------------------------------------------- 1. draws parameter plane for Fc(z)=z*z +c color shows in which quadrant zn lands. 4 colors are used because there are 4 quadrants : ------------------------------- 2. technic of creating ppm file is based on the code of Claudio Rocchinihttp://en.wikipedia.org/wiki/Image:Color_complex_plot.jpgcreate 8 bit color ( shades of gray) graphic file , portable pixmap file = PPM see http://en.wikipedia.org/wiki/Portable_pixmapto see the file use external application ( graphic viewer)---------------------------------Adam Majewskifraktal.republika.pl{{Date|2010|04|02}}*/#include<stdio.h>intmain(){/* screen ( integer) coordinate */intiX,iY;constintiXmax=4000;constintiYmax=4000;/* world ( double) coordinate = parameter plane*/doubleCx,Cy;constdoubleCxMin=-2.5;constdoubleCxMax=1.5;constdoubleCyMin=-2.0;constdoubleCyMax=2.0;/* */doublePixelWidth=(CxMax-CxMin)/iXmax;doublePixelHeight=(CyMax-CyMin)/iYmax;/* color component ( R or G or B) is coded from 0 to 255 *//* it is 24 bit color RGB file */constintMaxColorComponentValue=255;staticunsignedcharcolor[1];/* 8 bit color = 1 byte */FILE*fp;char*filename="d_9.ppm";char*comment="# ";/* comment should start with # *//* Z=Zx+Zy*i ; Z0 = 0 */doubleZx,Zy;doubleZx2,Zy2;/* Zx2=Zx*Zx; Zy2=Zy*Zy *//* */intIteration;constintIterationMax=9;/* bail-out value , radius of circle ; */constdoubleEscapeRadius=1000;doubleER2=EscapeRadius*EscapeRadius;/*create new file,give it a name and open it in binary mode */fp=fopen(filename,"wb");/* b - binary mode *//*write ASCII header to the file - 8 bit color*/fprintf(fp,"P5\n %s\n %d\n %d\n %d\n",comment,iXmax,iYmax,MaxColorComponentValue);/* compute and write image data bytes to the file*/for(iY=0;iY<iYmax;iY++){Cy=CyMin+iY*PixelHeight;if(fabs(Cy)<PixelHeight/2)Cy=0.0;/* Main antenna */for(iX=0;iX<iXmax;iX++){Cx=CxMin+iX*PixelWidth;/* initial value of orbit = critical point Z= 0 */Zx=0.0;Zy=0.0;Zx2=Zx*Zx;Zy2=Zy*Zy;/* */for(Iteration=0;Iteration<IterationMax;Iteration++){Zy=2*Zx*Zy+Cy;Zx=Zx2-Zy2+Cx;Zx2=Zx*Zx;Zy2=Zy*Zy;};/* compute pixel color (8 bit = 1 byte) */// if (Iteration==IterationMax) color[0]=0; /* interior of Mandelbrot set = black *//* exterior of Mandelbrot set = binary decomposition */// else if((Zx>0)&&(Zy>0))color[0]=50;/* 1-st quadrant */if((Zx<0)&&(Zy>0))color[0]=100;/* 2-nd quadrant */if((Zx<0)&&(Zy<0))color[0]=150;/* 3-rd quadrant */if((Zx>0)&&(Zy<0))color[0]=200;/* 4-th quadrant *//*write color to the file*/fwrite(color,1,1,fp);}}fclose(fp);printf("file saved\n");getchar();return0;}
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue
You may select the license of your choice.
Captions
Add a one-line explanation of what this file represents
Optimized with OxiPNG and ZopfliPNG. Hilariously, the filesize got LARGER when you shrank the image resolution! Just goes to show you how BAD most programs (including GIMP) are at encoding PNGs.
{{Information |Description ={{en|1=Mandelbrot set for fc(z)=z*z + c. Color of pixel is proportional to quadratn in which last iteration lands}} |Source ={{own}} |Author =Adam majewski |Date =2010-04-02 |