File:Quadratic Golden Mean Siegel Disc IIM Animated.gif
Quadratic_Golden_Mean_Siegel_Disc_IIM_Animated.gif (750 × 550 pixels, file size: 4.65 MB, MIME type: image/gif, looped, 101 frames, 51 s)
Captions
Summary
[edit]DescriptionQuadratic Golden Mean Siegel Disc IIM Animated.gif |
English: This image shows Julia set for Golden Mean made with IIM/J. For level 0 there is only main component ( containing Siegel Disk). For every next step ( up to level 100) 2 preimages under complex quadratic polynomial of every previous components are added . |
Date | |
Source | own work using C/gcc, BASH and ImageMagic |
Author | Adam majewski |
Other versions |
|
Licensing
[edit]- You are free:
- 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.
Compare with
[edit]-
Average velocity - color version
-
Average velocity - Gray and detailed version
-
Boundary made with MIIM
-
orbits inside Siegel disc
C src code
[edit]see this static image for code for one image.
Here is the code for sequence of images :
old C source code IIM/J ( all points ) - click on the right to view |
---|
a.c: |
/*
c console program
It can be compiled and run under Linux, windows, Mac
It needs gcc
--------------------------------------
draws Julia set for f(z)=z*z+c using IIM
( Inverse Iteration Method )
draws all points up to level
------------------------------------------
mogrify -format gif *.pgm // convert all our PGM images to the gif format:
convert -delay 100 -loop 0 *.gif animated.gif // make animated gif
convert -delay 100 -loop 0 %d.gif[0-10] a10.gif
one can change :
- LevelMax
- iSide ( width of image = iXmax = (15*iSide) it also changes IterationMax = (iXmax*50)
- NrOfCrOrbitPoints = 10 * iXmax;
-----------------------------------------
1.pgm file code is based on the code of Claudio Rocchini
http://en.wikipedia.org/wiki/Image:Color_complex_plot.jpg
create 8 bit color graphic file , portable gray map file = pgm
see http://en.wikipedia.org/wiki/Portable_pixmap
to see the file use external application ( graphic viewer)
I think that creating graphic can't be simpler
---------------------------
2. first it creates data array which is used to store color values of pixels,
fills tha array with data and after that writes the data from array to pgm file.
It alows free ( non sequential) acces to "pixels"
-------------------------------------------
Here are 4 items :
1. complex plane Z with points z = zx+zy*i ( dynamic plane and world coordinate )
2. virtual 2D array indexed by iX and iYmax ( integer or screen coordinate )
3. memory 1D arrays data ( and hits) indexed by i =f(iX,iY)
4. pgm file
Adam Majewski fraktal.republika.pl
to compile :
gcc a.c -lm -Wall
to run ( Linux console) :
./a.out
NrOfPoints = 15000 File 0.pgm
NrOfPoints = 44999 File 1.pgm
NrOfPoints = 104998 File 2.pgm
NrOfPoints = 224997 File 3.pgm
NrOfPoints = 464996 File 4.pgm
NrOfPoints = 944995 File 5.pgm
NrOfPoints = 1904994 File 6.pgm
NrOfPoints = 3824993 File 7.pgm
NrOfPoints = 7664992 File 8.pgm
NrOfPoints = 15344991 File 9.pgm
NrOfPoints = 30704990 File 10.pgm
NrOfPoints = 61424989 File 11.pgm
NrOfPoints = 61439999 File 12.pgm
NrOfPoints = 184319998 File 13.pgm
NrOfPoints = 430079997 File 14.pgm
NrOfPoints = 921599996 File 15.pgm
NrOfPoints = 1904639995 File 16.pgm
NrOfPoints = 3870719994 File 17.pgm
NrOfPoints = 3507912697 File 18.pgm
NrOfPoints = 2782298104 File 19.pgm
NrOfPoints = 1331068919 File 20.pgm
NrOfPoints = 1392508927 File 21.pgm
NrOfPoints = 4177526782 File 22.pgm
NrOfPoints = 1157627901 File 23.pgm
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* iXmax/iYmax = 11/15 */
const int iSide = 100;
int iXmax ; /* width of image in pixels = (15*iSide); */
int iYmax ;
int iLength ;
/* */
const double ZxMin = -1.5;
const double ZxMax = 1.5;
const double ZyMin = -1.1;
const double ZyMax = 1.1;
/* (ZxMax-ZxMin)/(ZyMax-ZyMin)= iXmax/iYmax */
double PixelWidth ;
double PixelHeight ;
unsigned int NrOfPoints = 0;
unsigned int NrOfCrOrbitPoints ;
unsigned int LevelMax = 30; /* nr of points = sum(2^LevelMax) */
/* fc(z) = z*z + c */
/* Golden_Mean_Quadratic_Siegel_Disc */
const double Cx = -0.390540870218399; /* C = Cx + Cy*i */
const double Cy = -0.586787907346969;
/* colors */
const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ; it is 8 bit color file */
const int iExterior = 245; /* exterior of Julia set */
const int iJulia = 0; /* border , boundary*/
const int iInterior = 230;
/* ----------------------- functions ---------------------------------------- */
/* gives sign of number */
double sign(double d)
{
if (d<0)
{return -1.0;}
else {return 1.0;};
};
unsigned int f(unsigned int iX, unsigned int iY)
/*
gives position of point (iX,iY) in 1D array ; uses also global variables
it does not check if index is good so memory error is possible
*/
{return (iX + (iYmax- iY-1)*iXmax );}
int DrawPoint( double Zx, double Zy, unsigned char data[])
{
unsigned int iX,iY; /* indices of 2D virtual array (image) = integer coordinate */
unsigned int index; /* index of 1D array */
iX = (int)((Zx-ZxMin)/PixelWidth);
iY = (int)((Zy-ZyMin)/PixelHeight);
index = f(iX,iY);
data[index] = iJulia; /* draw */
NrOfPoints += 1 ;
return 0;
}
int DrawPointAndItsInverseOrbit( double Zx, double Zy, unsigned int LevelMax, unsigned char data[])
{
double NewZx, NewZy;
unsigned int Level = 1;
/* draw point */
DrawPoint(Zx,Zy,data);
/* compute and draw all preimages up to LevelMax */
while (Level<LevelMax)
{
/* Zn*Zn=Z(n+1)-c */
Zx=Zx-Cx;
Zy=Zy-Cy;
/* sqrt of complex number algorithm from Peitgen, Jurgens, Saupe: Fractals for the classroom */
if (Zx>0)
{
NewZx=sqrt((Zx+sqrt(Zx*Zx+Zy*Zy))/2);
NewZy=Zy/(2*NewZx);
}
else /* ZX <= 0 */
{
if (Zx<0)
{
NewZy=sign(Zy)*sqrt((-Zx+sqrt(Zx*Zx+Zy*Zy))/2);
NewZx=Zy/(2*NewZy);
}
else /* Zx=0 */
{
NewZx=sqrt(fabs(Zy)/2);
if (NewZx>0) NewZy=Zy/(2*NewZx);
else NewZy=0;
}
};
DrawPoint(NewZx,NewZy,data);
/* save point and its level to the stack */
DrawPointAndItsInverseOrbit(-NewZx,-NewZy,LevelMax - Level ,data);
/* */
Zx=NewZx;
Zy=NewZy;
Level+=1;
}
/* draw points from stack */
return 0;
}
int Draw(unsigned int pointMax, unsigned int LevelMax, unsigned char data[])
{
unsigned int point; /* nr of point of critical orbit */
double Zx,Zy;
double Zx2,Zy2;
/* critical point z = 0 */
Zx = 0.0;
Zy = 0.0;
DrawPointAndItsInverseOrbit(Zx,Zy,LevelMax,data);
Zx2=Zx*Zx;
Zy2=Zy*Zy;
/* forward orbit of critical point = critical orbit */
for (point=2;point<=pointMax ;point++)
{
/* f(z) = z*z+c */
Zy=2*Zx*Zy + Cy;
Zx=Zx2-Zy2 +Cx;
Zx2=Zx*Zx;
Zy2=Zy*Zy;
/* draws critical orbit */
DrawPoint(Zx,Zy,data); /* main component with Siegel Disc */
/* symmetric point for each point of critical orbit */
/* recurrence version is easy to do */
if (LevelMax>0) DrawPointAndItsInverseOrbit(-Zx,-Zy, LevelMax, data);
// printf(" row %u from %u \n",point, pointMax); /* progres info */
}
return 0;
}
/* --------------------------------------------------------------------------------------------------------- */
int main(){
unsigned int level;
/* unsigned int iX,iY; indices of 2D virtual array (image) = integer coordinate */
iXmax = (15*iSide); /* height of image in pixels */
iYmax = (11*iSide);
iLength = (iXmax*iYmax);
NrOfCrOrbitPoints = 10 * iXmax;
PixelWidth = ((ZxMax-ZxMin)/iXmax);
PixelHeight = ((ZyMax-ZyMin)/iYmax);
/* dynamic 1D arrays for colors ( shades of gray ) and hits */
unsigned int index; /* index of 1D array */
unsigned char *data;
data = malloc( iLength * sizeof(unsigned char) );
if (data == NULL )
{
fprintf(stderr," Could not allocate memory");
return 1;
}
else printf(" memory is OK\n");
for (level=0;level<=LevelMax ;level++)
{
for(index=0;index<iLength-1;++index) data[index]=iExterior; /* clear data */
/* ------------------ draw ----------------------- */
//printf(" Draw %u points of critical orbit and its preimages \n",NrOfCrOrbitPoints);
Draw(NrOfCrOrbitPoints,level, data);
printf(" NrOfPoints = %u \n", NrOfPoints);
/* ---------- file -------------------------------------*/
//printf(" save data array to the pgm file \n");
FILE * fp;
char name [10]; /* name of file */
sprintf(name,"%u",level); /* */
char *filename =strcat(name,".pgm");
char *comment="# C= ";/* comment should start with # */
/* save image to the pgm file */
fp= fopen(filename,"wb"); /*create new file,give it a name and open it in binary mode */
fprintf(fp,"P5\n %s\n %u\n %u\n %u\n",comment,iXmax,iYmax,MaxColorComponentValue); /*write header to the file*/
fwrite(data,iLength,1,fp); /*write image data bytes to the file in one step */
printf("File %s saved. \n", filename);
fclose(fp);
} /* level */
/* --------------free memory ---------------------*/
free(data);
return 0;
}
|
New C source code ( hit limit ) - click on the right to view |
---|
a.c: |
/*
c console program
It can be compiled and run under Linux, windows, Mac
It needs gcc
--------------------------------------
draws Julia set for f(z)=z*z+c using IIM
( Inverse Iteration Method )
modifications - hits table : if (hits[index]<HitMax)
------------------------------------------
mogrify -format gif *.pgm // convert all our PGM images to the gif format:
convert 0.pgm -pointsize 100 -annotate +10+100 '0' 0.png
convert -delay 100 -loop 0 *.gif animated.gif // make animated gif
convert -delay 100 -loop 0 %d.gif[0-10] a10.gif
ffmpeg -f image2 -i %d.gif a25.mpg
convert -delay 100 -loop 0 %d.gif[0-25] a25.mpg
one can change :
- HitMax
- iSide ( width of image = iXmax = (15*iSide) it also changes IterationMax = (iXmax*50)
- NrOfCrOrbitPoints = 10 * iXmax;
-----------------------------------------
1.pgm file code is based on the code of Claudio Rocchini
http://en.wikipedia.org/wiki/Image:Color_complex_plot.jpg
create 8 bit color graphic file , portable gray map file = pgm
see http://en.wikipedia.org/wiki/Portable_pixmap
to see the file use external application ( graphic viewer)
I think that creating graphic can't be simpler
---------------------------
2. first it creates data array which is used to store color values of pixels,
fills tha array with data and after that writes the data from array to pgm file.
It alows free ( non sequential) acces to "pixels"
-------------------------------------------
Here are 4 items :
1. complex plane Z with points z = zx+zy*i ( dynamic plane and world coordinate )
2. virtual 2D array indexed by iX and iYmax ( integer or screen coordinate )
3. memory 1D array data indexed by i =f(iX,iY)
4. pgm file
Adam Majewski fraktal.republika.pl
to compile :
gcc h.c -lm -Wall
to run ( Linux console) :
./a.out
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
unsigned int NrOfPoints = 0;
unsigned int NrOfCrOrbitPoints ;
unsigned int HitMax = 10; /* how many times z can be inside pixel */
unsigned int LevelMax = 100; /* nr of points = sum(2^LevelMax) */
/* iXmax/iYmax = 11/15 */
const int iSide = 100;
int iXmax ; /* width of image in pixels = (15*iSide); */
int iYmax ;
int iLength ;
/* */
const double ZxMin = -1.5;
const double ZxMax = 1.5;
const double ZyMin = -1.1;
const double ZyMax = 1.1;
/* (ZxMax-ZxMin)/(ZyMax-ZyMin)= iXmax/iYmax */
double PixelWidth ;
double PixelHeight ;
/* fc(z) = z*z + c */
/* Golden_Mean_Quadratic_Siegel_Disc */
const double Cx = -0.390540870218399; /* C = Cx + Cy*i */
const double Cy = -0.586787907346969;
/* colors */
const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ; it is 8 bit color file */
const int iExterior = 245; /* exterior of Julia set */
const int iJulia = 0; /* border , boundary*/
const int iInterior = 230;
/* ----------------------- functions ---------------------------------------- */
/* gives sign of number */
double sign(double d)
{
if (d<0)
{return -1.0;}
else {return 1.0;};
};
unsigned int f(unsigned int iX, unsigned int iY)
/*
gives position of point (iX,iY) in 1D array ; uses also global variables
it does not check if index is good so memory error is possible
*/
{return (iX + (iYmax- iY-1)*iXmax );}
int DrawPoint( double Zx, double Zy, unsigned char data[], unsigned char hits[])
{
unsigned int iX,iY; /* indices of 2D virtual array (image) = integer coordinate */
unsigned int index; /* index of 1D array */
/* I do not why but some points escape ; I cant find an error but it is
probably in code for finding preimages */
if (Zx>ZxMax || Zx<ZxMin || Zy>ZyMax || Zy<ZyMin) return 1;
iX = (int)((Zx-ZxMin)/PixelWidth);
iY = (int)((Zy-ZyMin)/PixelHeight);
index = f(iX,iY);
if (hits[index]>HitMax) return 1; /* stop if pixel is hit to often */
data[index] = iJulia; /* draw */
hits[index] +=1;
NrOfPoints += 1 ;
return 0;
}
int DrawPointAndItsInverseOrbit( double Zx, double Zy, unsigned int LevelMax, unsigned char data[], unsigned char hits[])
{
double NewZx, NewZy;
unsigned int Level = 1; /* start from 1 to LevelMax */
/* draw point */
DrawPoint(Zx,Zy,data, hits);
/* compute and draw all preimages up to LevelMax */
while (Level<LevelMax)
{
/* Zn*Zn=Z(n+1)-c */
Zx=Zx-Cx;
Zy=Zy-Cy;
/* sqrt of complex number algorithm from Peitgen, Jurgens, Saupe: Fractals for the classroom */
if (Zx>0.0)
{ NewZx=sqrt((Zx+sqrt(Zx*Zx+Zy*Zy))/2);
NewZy=Zy/(2*NewZx); }
else /* ZX <= 0 */
{
if (Zx<0.0)
{ NewZy=sign(Zy)*sqrt((-Zx+sqrt(Zx*Zx+Zy*Zy))/2);
NewZx=Zy/(2*NewZy); }
else /* Zx=0 */
{ NewZx=sqrt(fabs(Zy)/2);
if (NewZx>0) NewZy=Zy/(2*NewZx);
else NewZy=0.0; }
};
/* I do not why but some points escape ; I cant find an error but it is
probably in code for finding preimages */
/* try to check point if not escaping and hit<hit limit then draw it */
if( DrawPoint(NewZx,NewZy,data, hits)) Level=LevelMax; /* if not go to next point */
DrawPointAndItsInverseOrbit(-NewZx,-NewZy,LevelMax - Level ,data, hits);
Zx=NewZx;
Zy=NewZy;
Level+=1;
}
return 0;
}
int Draw(unsigned int pointMax, unsigned int LevelMax, unsigned char data[] , unsigned char hits[])
{
unsigned int point; /* nr of point of critical orbit */
double Zx,Zy;
double Zx2,Zy2;
/* critical point z = 0 */
Zx = 0.0;
Zy = 0.0;
DrawPointAndItsInverseOrbit(Zx,Zy,LevelMax,data, hits);
Zx2=Zx*Zx;
Zy2=Zy*Zy;
/* forward orbit of critical point = critical orbit */
for (point=2;point<=pointMax ;point++)
{
/* f(z) = z*z+c */
Zy=2*Zx*Zy + Cy;
Zx=Zx2-Zy2 + Cx;
Zx2=Zx*Zx;
Zy2=Zy*Zy;
/* draws critical orbit */
DrawPoint(Zx,Zy,data, hits); /* main component with Siegel Disc */
/* symmetric point for each point of critical orbit */
if (LevelMax>0) DrawPointAndItsInverseOrbit(-Zx,-Zy, LevelMax, data, hits);
//printf(" row %u from %u \n",point, pointMax); /* progres info */
}
return 0;
}
/* --------------------------------------------------------------------------------------------------------- */
int main(){
unsigned int level;
/* unsigned int iX,iY; indices of 2D virtual array (image) = integer coordinate */
iXmax = (15*iSide); /* height of image in pixels */
iYmax = (11*iSide);
iLength = (iXmax*iYmax);
NrOfCrOrbitPoints = 10 * iXmax;
PixelWidth = ((ZxMax-ZxMin)/iXmax);
PixelHeight = ((ZyMax-ZyMin)/iYmax);
/* dynamic 1D arrays for colors ( shades of gray ) and hits */
unsigned int index; /* index of 1D array */
unsigned char *data;
unsigned char *hits;
data = malloc( iLength * sizeof(unsigned char) );
hits = malloc( iLength * sizeof(unsigned char) );
if (data == NULL || hits==NULL )
{
fprintf(stderr," Could not allocate memory");
return 1;
}
else printf(" memory is OK\n");
for (level=0;level<=LevelMax ;level++)
{
for(index=0;index<iLength-1;++index)
{ data[index]=iExterior; /* clear data */
hits[index]=0; }
/* ------------------ draw ----------------------- */
//printf(" Draw %u points of critical orbit and its preimages \n",NrOfCrOrbitPoints);
Draw(NrOfCrOrbitPoints,level, data, hits);
printf(" NrOfPoints = %u \n", NrOfPoints);
/* ---------- file -------------------------------------*/
//printf(" save data array to the pgm file \n");
FILE * fp;
char name [10]; /* name of file */
sprintf(name,"%u",level); /* */
char *filename =strcat(name,".pgm");
char *comment="# C= ";/* comment should start with # */
/* save image to the pgm file */
fp= fopen(filename,"wb"); /*create new file,give it a name and open it in binary mode */
fprintf(fp,"P5\n %s\n %u\n %u\n %u\n",comment,iXmax,iYmax,MaxColorComponentValue); /*write header to the file*/
fwrite(data,iLength,1,fp); /*write image data bytes to the file in one step */
printf("File %s saved. \n", filename);
fclose(fp);
} /* level */
/* --------------free memory ---------------------*/
free(data);
free(hits);
return 0;
}
|
Bash and Image Magic src code
[edit]Convert sequence of pgm images into animated gif ( with text label )
#!/bin/bash
# script file for BASH
# which bash
# save this file as g
# chmod +x g
# ./g
# for all pgm files in this directory
for file in *.pgm ; do
# b is name of file without extension
b=$(basename $file .pgm)
# convert from pgm to gif and add text ( level ) using ImageMagic
convert $file -pointsize 100 -annotate +10+100 $b ${b}.gif
echo $file
done
# convert gif files to animated gif
convert -delay 100 -loop 0 %d.gif[0-24] a24.gif
echo OK
# end
It was to big ( > 12.5MP limit ) :
convert a24.gif -resize 750x550 a24s.gif
New file is up to 100 level and is still > 12.5 MP limit but smaller would be not good.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 17:25, 17 November 2011 | 750 × 550 (4.65 MB) | Soul windsurfer (talk | contribs) | up to level 100 | |
16:34, 14 November 2011 | 750 × 550 (872 KB) | Soul windsurfer (talk | contribs) | 25 version | ||
21:57, 13 November 2011 | 750 × 550 (718 KB) | Soul windsurfer (talk | contribs) | smaller size | ||
21:34, 13 November 2011 | 1,500 × 1,100 (531 KB) | Soul windsurfer (talk | contribs) |
You cannot overwrite this file.
File usage on Commons
The following 4 pages use this file:
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on en.wikibooks.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
GIF file comment | C= |
---|