קובץ:A parabolic checkerboard for rotation number 1 over 2.png
תוכן הדף אינו נתמך בשפות אחרות.
מראה
מתוך ויקיפדיה, האנציקלופדיה החופשית
גודל התצוגה המקדימה הזאת: 600 × 600 פיקסלים. רזולוציות אחרות: 240 × 240 פיקסלים | 480 × 480 פיקסלים | 1,000 × 1,000 פיקסלים.
לקובץ המקורי (1,000 × 1,000 פיקסלים, גודל הקובץ: 72 ק"ב, סוג MIME: image/png)
זהו קובץ שמקורו במיזם ויקישיתוף. תיאורו בדף תיאור הקובץ המקורי (בעברית) מוצג למטה. |
תוכן עניינים
תקציר
תיאורA parabolic checkerboard for rotation number 1 over 2.png |
English: A parabolic checkerboard for rotation number 1 over 2 = ternary decomposition of interior in parabolic case |
תאריך יצירה | |
מקור | נוצר על־ידי מעלה היצירה |
יוצר | Adam majewski |
Compare with
-
binary decomposition of interior and exterior
-
Level sets of attraction time
-
boundary = Julia set
-
checkerboard for rotation number 1/1
רישיון
אני, בעל זכויות היוצרים על עבודה זו, מפרסם בזאת את העבודה תחת הרישיון הבא:
הקובץ הזה מתפרסם לפי תנאי רישיון קריאייטיב קומונז ייחוס-שיתוף זהה 4.0 בין־לאומי.
- הנכם רשאים:
- לשתף – להעתיק, להפיץ ולהעביר את העבודה
- לערבב בין עבודות – להתאים את העבודה
- תחת התנאים הבאים:
- ייחוס – יש לתת ייחוס הולם, לתת קישור לרישיון, ולציין אם נעשו שינויים. אפשר לעשות את זה בכל צורה סבירה, אבל לא בשום צורה שמשתמע ממנה שמעניק הרישיון תומך בך או בשימוש שלך.
- שיתוף זהה – אם תיצרו רמיקס, תשנו, או תבנו על החומר, חובה עליכם להפיץ את התרומות שלך לפי תנאי רישיון זהה או תואם למקור.
C src code
/*
Adam Majewski
adammaj1 aaattt o2 dot pl // o like oxygen not 0 like zero
fraktal.republika.pl
c console progam
gcc c.c -lm -Wall -march=native
time ./a.out
gcc c.c -lm -Wall -march=native -fopenmp
method of filling gaps in rays turns
should be the same as for drawing rays !!!!!!!!!!!!!
!!!!!---------- algorithm ---------!!!!!!!!
trap ( target set) for iteration :
* of interior points = interior of circle centered at alfa and radius = dMaxDistance2Alfa, with iPeriodChild sectors described by periodic external rays landing on alfa
* of exterior points = exterior of circle centered at origin ( z=0) and radius = ER
Iterate point until it fails to one of 2 traps.
If it it fail into interior trap then check in which sector is it. Color = number of sector
Interior target set should be all inside Julia set
( of course not counting external rays that cross it and exterior parts which are very thin = means width < pixelwidth)
if it is a circle around alfa then it shrinks as iPeriodOfChild grows
( = time of creating image grows)
-----------------------------------------
Better is to take as a interior target set :
part of this circle bordered by 2 external rays
(One can choose the longest one !!!)
and color the interior proportionaly to
(i % iPeriodOfChild)
./a.out
without openmp
real 7m54.710s
user 7m54.861s
sys 0m0.008s
with openmp :
real 1m47.034s
user 14m8.420s
sys 0m0.280s
*/
#include <stdio.h>
#include <stdlib.h> // malloc
#include <string.h> // strcat
#include <math.h> // M_PI; needs -lm also
#include <complex.h>
#include <omp.h>
/* --------------------------------- global variables and consts ------------------------------------------------------------ */
#define iPeriodChild 2 // Period of secondary component joined by root point with the parent component
int iPeriodParent = 1; // main cardioid of Mandelbrot set
// radius of the target set ( circle around alfa fixed point ); it is related with iHeight
// so changing iHeight needs change of iMaxDistance2Alfa
int iMaxDistance2Alfa = 1; // distance point to alfa fixed point in pixels 150 when iHeight=1000; 280 when iHeight=2000
double dMaxDistance2Alfa2; // = (iMaxDistance2Alfa*PixelWidth)^2
double dMaxDistance2Alfa;
// virtual 2D array and integer ( screen) coordinate
// Indexes of array starts from 0 not 1
//unsigned int ix, iy; // var
static unsigned int ixMin = 0; // Indexes of array starts from 0 not 1
static unsigned int ixMax ; //
static unsigned int iWidth ; // horizontal dimension of array
static unsigned int iyMin = 0; // Indexes of array starts from 0 not 1
static unsigned int iyMax ; //
static unsigned int iHeight = 3000; //
// The size of array has to be a positive constant integer
static unsigned int iSize ; // = iWidth*iHeight;
// memmory 1D array
unsigned char *data;
unsigned char *edge;
// unsigned int i; // var = index of 1D array
//static unsigned int iMin = 0; // Indexes of array starts from 0 not 1
static unsigned int iMax ; // = i2Dsize-1 =
// The size of array has to be a positive constant integer
// unsigned int i1Dsize ; // = i2Dsize = (iMax -iMin + 1) = ; 1D array with the same size as 2D array
/* world ( double) coordinate = dynamic plane */
static const double ZxMin=-1.5;
static const double ZxMax=1.5;
static const double ZyMin=-1.5;
static const double ZyMax=1.5;
static double PixelWidth; // =(ZxMax-ZxMin)/ixMax;
static double PixelHeight; // =(ZyMax-ZyMin)/iyMax;
static double ratio ;
// complex numbers of parametr plane
double Cx; // c =Cx +Cy * i
double Cy;
double complex c; // parameter of function fc(z)=z^2 + c
double complex alfa; // alfa fixed point alfa=f(alfa)
double dAlfaX, dAlfaY;
int iAlfaX, iAlfaY;
static unsigned long int iterMax = 10000000; //iHeight*100;
static double ER = 2.0; // Escape Radius for bailout test
static double ER2;
/* colors = shades of gray from 0 to 255 */
// 8 bit color = int number from 0 to 255
// Arrays are 0-indexed, so the first array element is at index = 0, and the highest is =(size_of_array – 1)
unsigned char iColorInterior[2][iPeriodChild]={{255,231}, {123,99}}; /* shades of gray used in image */
unsigned char iColorsOfInterior[iPeriodChild]; //={255,230,180, 160,140,120,100}; // NumberOfPetal of colors = iPeriodChild
static unsigned char iColorOfExterior = 245;
unsigned char iColorOfUnknown = 133;
int iNumberOfUknknown = 0;
static double TwoPi=2*M_PI;
/* ------------------------------------------ functions -------------------------------------------------------------*/
/* find c in component of Mandelbrot set
uses code by Wolf Jung from program Mandel
see function mndlbrot::bifurcate from mandelbrot.cpp
http://www.mndynamics.com/indexp.html
*/
double complex GiveC(double InternalAngleInTurns, double InternalRadius, unsigned int iPeriodOfTheParent)
{
//0 <= InternalRay<= 1
//0 <= InternalAngleInTurns <=1
double t = InternalAngleInTurns *2*M_PI; // from turns to radians
double R2 = InternalRadius * InternalRadius;
//double Cx, Cy; /* C = Cx+Cy*i */
switch ( iPeriodOfTheParent ) // of component
{
case 1: // main cardioid
Cx = (cos(t)*InternalRadius)/2-(cos(2*t)*R2)/4;
Cy = (sin(t)*InternalRadius)/2-(sin(2*t)*R2)/4;
break;
case 2: // only one component
Cx = InternalRadius * 0.25*cos(t) - 1.0;
Cy = InternalRadius * 0.25*sin(t);
break;
// for each iPeriodOfTheParent there are 2^(iPeriodOfTheParent-1) roots.
default: // higher periods : not works, to do
Cx = 0.0;
Cy = 0.0;
break; }
return Cx + Cy*I;
}
/*
http://en.wikipedia.org/wiki/Periodic_points_of_complex_quadratic_mappings
z^2 + c = z
z^2 - z + c = 0
ax^2 +bx + c =0 // ge3neral for of quadratic equation
so :
a=1
b =-1
c = c
so :
The discriminant is the d=b^2- 4ac
d=1-4c = dx+dy*i
r(d)=sqrt(dx^2 + dy^2)
sqrt(d) = sqrt((r+dx)/2)+-sqrt((r-dx)/2)*i = sx +- sy*i
x1=(1+sqrt(d))/2 = beta = (1+sx+sy*i)/2
x2=(1-sqrt(d))/2 = alfa = (1-sx -sy*i)/2
alfa : attracting when c is in main cardioid of Mandelbrot set, then it is in interior of Filled-in Julia set,
it means belongs to Fatou set ( strictly to basin of attraction of finite fixed point )
*/
// uses global variables :
// ax, ay (output = alfa(c))
double complex GiveAlfaFixedPoint(double complex c)
{
double dx, dy; //The discriminant is the d=b^2- 4ac = dx+dy*i
double r; // r(d)=sqrt(dx^2 + dy^2)
double sx, sy; // s = sqrt(d) = sqrt((r+dx)/2)+-sqrt((r-dx)/2)*i = sx + sy*i
double ax, ay;
// d=1-4c = dx+dy*i
dx = 1 - 4*creal(c);
dy = -4 * cimag(c);
// r(d)=sqrt(dx^2 + dy^2)
r = sqrt(dx*dx + dy*dy);
//sqrt(d) = s =sx +sy*i
sx = sqrt((r+dx)/2);
sy = sqrt((r-dx)/2);
// alfa = ax +ay*i = (1-sqrt(d))/2 = (1-sx + sy*i)/2
ax = 0.5 - sx/2.0;
ay = sy/2.0;
return ax+ay*I;
}
// colors of components interior = shades of gray
int InitColors(int iMax, unsigned char iColors[])
{
int i;
//int iMax = iPeriodChild; iPeriodChild and iColorsOfInterior
unsigned int iStep;
iStep= 40 ; //150/iMax;
for (i = 1; i <= iMax; ++i)
{
iColors[i-1] = iColorOfExterior -i*iStep;
printf("i= %d color = %i \n",i-1, iColors[i-1]); // debug
}
return 0;
}
//------------------complex numbers -----------------------------------------------------
// gives argument of complex number in turns
// realted with alfa fixed point
// http://en.wikipedia.org/wiki/Turn_%28geometry%29
double GiveTurn(double zx, double zy)
{
double argument;
argument =atan2(zy, zx);// carg(zx +zy*I ); argument in radians from -pi to pi
if (argument<0) argument=argument + TwoPi; // argument in radians from 0 to 2*pi
return argument/TwoPi ; // argument in turns from 0.0 to 1.0
}
/*
principal square root of complex number
http://en.wikipedia.org/wiki/Square_root
z1= I;
z2 = root(z1);
printf("zx = %f \n", creal(z2));
printf("zy = %f \n", cimag(z2));
*/
double complex root(double x, double y)
{
double u;
double v;
double r = sqrt(x*x + y*y);
v = sqrt(0.5*(r - x));
if (y < 0) v = -v;
u = sqrt(0.5*(r + x));
return u + v*I;
}
// from screen to world coordinate ; linear mapping
// uses global cons
double GiveZx(unsigned int ix)
{ return (ZxMin + ix*PixelWidth );}
// uses globaal cons
double GiveZy(unsigned int iy)
{ return (ZyMax - iy*PixelHeight);} // reverse y axis
/* ----------- array functions = drawing -------------- */
/* gives position of 2D point (ix,iy) in 1D array ; uses also global variable iWidth */
unsigned int Give_i(unsigned int ix, unsigned int iy)
{ return ix + iy*iWidth; }
// plots raster point (ix,iy)
int iDrawPoint(unsigned char A[], unsigned int ix, unsigned int iy, unsigned char iColor)
{
/* i = Give_i(ix,iy) compute index of 1D array from indices of 2D array */
A[Give_i(ix,iy)] = iColor;
return 0;
}
// draws point to memmory array data
// uses complex type so #include <complex.h> and -lm
int dDrawPoint(unsigned char A[], complex double point,unsigned char iColor )
{
unsigned int ix, iy; // screen coordinate = indices of virtual 2D array
//unsigned int i; // index of 1D array
ix = (creal(point)- ZxMin)/PixelWidth;
iy = (ZyMax - cimag(point))/PixelHeight; // inverse Y axis
iDrawPoint(A, ix, iy, iColor);
return 0;
}
//;;;;;;;;;;;;;;;;;;;;;; setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
int setup(int ParentPeriod, int ChildPeriod)
{
unsigned int denominator;
double InternalAngle;
printf("setup\n");
denominator = ChildPeriod;
InternalAngle = 1.0/((double) denominator);
c = GiveC(InternalAngle, 1.0, ParentPeriod) ; // internal radius= 1.0 gives root point = parabolic parameter
Cx=creal(c);
Cy=cimag(c);
alfa = GiveAlfaFixedPoint(c);
dAlfaX = creal(alfa);
dAlfaY = cimag(alfa);
iAlfaX = (dAlfaX- ZxMin)/PixelWidth;
iAlfaY = (ZyMax - dAlfaY)/PixelHeight; // inverse Y axis
/* 2D array ranges */
if (!(iHeight % 2)) iHeight+=1; // it sholud be even number (variable % 2) or (variable & 1)
iWidth = iHeight;
iSize = iWidth*iHeight; // size = number of points in array
// iy
iyMax = iHeight - 1 ; // Indexes of array starts from 0 not 1 so the highest elements of an array is = array_name[size-1].
//ix
ixMax = iWidth - 1;
/* 1D array ranges */
// i1Dsize = i2Dsize; // 1D array with the same size as 2D array
iMax = iSize-1; // Indexes of array starts from 0 not 1 so the highest elements of an array is = array_name[size-1].
/* Pixel sizes */
PixelWidth = (ZxMax-ZxMin)/ixMax; // ixMax = (iWidth-1) step between pixels in world coordinate
PixelHeight = (ZyMax-ZyMin)/iyMax;
ratio = ((ZxMax-ZxMin)/(ZyMax-ZyMin))/((float)iWidth/(float)iHeight); // it should be 1.000 ...
// for numerical optimisation in iteration
ER2 = ER * ER;
dMaxDistance2Alfa = PixelWidth*iMaxDistance2Alfa; // trap around fixed point
dMaxDistance2Alfa2 = dMaxDistance2Alfa* dMaxDistance2Alfa; //
/* create dynamic 1D arrays for colors ( shades of gray ) */
data = malloc( iSize * sizeof(unsigned char) );
edge = malloc( iSize * sizeof(unsigned char) );
if (edge== NULL || data == NULL)
{
fprintf(stderr," Could not allocate memory");
getchar();
return 1;
}
// fill array iColorsOfInterior with iPeriodChild colors ( shades of gray )
InitColors(iPeriodChild, iColorsOfInterior);
printf(" end of setup \n");
return 0;
} // ;;;;;;;;;;;;;;;;;;;;;;;;; end of the setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
unsigned char ComputeColor(unsigned int ix, unsigned int iy, int IterationMax)
{
// check behavour of z under fc(z)=z^2+c
// using 2 target set:
// 1. exterior or circle (center at origin and radius ER )
// as a target set containing infinity = for escaping points ( bailout test)
// for points of exterior of julia set
// 2. interior of circle with center = alfa and radius dMaxDistance2Alfa
// as a target set for points of interior of Julia set
// Z= Zx+ZY*i;
double Zx2, Zy2;
int i=0; // number of the iteration = fc(z)
double d2 ; /* d2= (distance from z to Alpha)^2 */
double Zxt,Zyt ; //
double Zx, Zy;
int m,n;
// from screen to world coordinate
Zx = GiveZx(ix);
Zy = GiveZy(iy);
/* distance from z to Alpha */
Zxt=Zx-dAlfaX;
Zyt=Zy-dAlfaY;
d2=Zxt*Zxt +Zyt*Zyt;
if (d2<dMaxDistance2Alfa2)
{
return iColorsOfInterior[i % iPeriodChild];
}
// if not inside target set around attractor ( alfa fixed point )
while (1 )
{ // then iterate
Zx2 = Zx*Zx;
Zy2 = Zy*Zy;
// bailout test
if (Zx2 + Zy2 > ER2) return iColorOfExterior; // if escaping stop iteration
// if not escaping or not attracting then iterate = check behaviour
// new z : Z(n+1) = Zn * Zn + C
Zy = 2*Zx*Zy + Cy;
Zx = Zx2 - Zy2 + Cx;
//
i+=1;
if (i > IterationMax) break;
/* distance from z to Alpha */
Zxt=Zx-dAlfaX;
Zyt=Zy-dAlfaY;
d2=Zxt*Zxt +Zyt*Zyt;
// check if fall into internal target set = interior
if (d2<dMaxDistance2Alfa2)
{
m = (Zyt > 0 ? 0 : 1); // part of the target set
n = (i % iPeriodChild); // attraction time
return iColorInterior[m][n];
}
}
iNumberOfUknknown +=1;
return iColorOfUnknown; //
}
// plots raster point (ix,iy)
int PlotPoint(unsigned char A[] , unsigned int ix, unsigned int iy, int IterationMax)
{
unsigned i; /* index of 1D array */
unsigned char iColor;
i = Give_i(ix,iy); /* compute index of 1D array from indices of 2D array */
iColor = ComputeColor(ix, iy, IterationMax);
A[i] = iColor;
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int ComputeFatouComponents(unsigned char A[], int IterationMax )
{
unsigned int ix, iy; // pixel coordinate
//printf("compute image \n");
// for all pixels of image
#pragma omp parallel for schedule(dynamic) private(ix,iy) shared(ixMax , iyMax, IterationMax)
for(iy = iyMin; iy<=iyMax; ++iy)
{ printf(" %d z %d \r", iy, iyMax); //info
for(ix= ixMin; ix<=ixMax; ++ix) PlotPoint(A, ix, iy, IterationMax ) ; //
}
return 0;
}
int ComputeBoundariesIn(unsigned char A[])
{
unsigned int iX,iY; /* indices of 2D virtual array (image) = integer coordinate */
unsigned int i; /* index of 1D array */
/* sobel filter */
unsigned char G, Gh, Gv;
// boundaries are in edge array ( global var )
printf(" find boundaries in A array using Sobel filter\n");
// #pragma omp parallel for schedule(dynamic) private(i,iY,iX,Gv,Gh,G) shared(iyMax,ixMax, ER2)
for(iY=1;iY<iyMax-1;++iY){
for(iX=1;iX<ixMax-1;++iX){
Gv= A[Give_i(iX-1,iY+1)] + 2*A[Give_i(iX,iY+1)] + A[Give_i(iX-1,iY+1)] - A[Give_i(iX-1,iY-1)] - 2*A[Give_i(iX-1,iY)] - A[Give_i(iX+1,iY-1)];
Gh= A[Give_i(iX+1,iY+1)] + 2*A[Give_i(iX+1,iY)] + A[Give_i(iX-1,iY-1)] - A[Give_i(iX+1,iY-1)] - 2*A[Give_i(iX-1,iY)] - A[Give_i(iX-1,iY-1)];
G = sqrt(Gh*Gh + Gv*Gv);
i= Give_i(iX,iY); /* compute index of 1D array from indices of 2D array */
if (G==0) {edge[i]=255;} /* background */
else {edge[i]=0;} /* boundary */
}
}
return 0;
}
int CopyBoundariesTo(unsigned char A[])
{
unsigned int iX,iY; /* indices of 2D virtual array (image) = integer coordinate */
unsigned int i; /* index of 1D array */
printf("copy boundaries from edge array to data array \n");
for(iY=1;iY<iyMax-1;++iY)
for(iX=1;iX<ixMax-1;++iX)
{i= Give_i(iX,iY); if (edge[i]==0) A[i]=0;}
return 0;
}
int DrawCriticalOrbit(unsigned char A[], unsigned int IterMax)
{
// integer = pixel coordinate
unsigned int ix, iy;
// double = world coordinate
// critical point Z= Zx+ZY*i;
double Zx=0.0;
double Zy=0.0;
double Zx2=0.0;
double Zy2=0.0;
unsigned int i; /* index of 1D array */
unsigned int j; // number of iteration
// draw critical point
ix = (int)((Zx-ZxMin)/PixelWidth);
iy = (int)((ZyMax-Zy)/PixelHeight); // reverse y axis
i = Give_i(ix, iy); /* compute index of 1D array from indices of 2D array */
A[i]=255-A[i];
// iterate
for (j = 1; j <= IterMax; j++) //larg number of iteration s
{ Zx2 = Zx*Zx;
Zy2 = Zy*Zy;
// bailout test
if (Zx2 + Zy2 > ER2) return iColorOfExterior; // if escaping stop iteration
// if not escaping iterate
// Z(n+1) = Zn * Zn + C
Zy = 2*Zx*Zy + Cy;
Zx = Zx2 - Zy2 + Cx;
//compute integer coordinate
ix = (int)((Zx-ZxMin)/PixelWidth);
iy = (int)((ZyMax-Zy)/PixelHeight); // reverse y axis
i = Give_i(ix, iy); /* compute index of 1D array from indices of 2D array */
A[i]=0; //255-A[i]; // mark the critical orbit
}
return 0;
}
// Check Orientation of image : mark first quadrant
// it should be in the upper right position
// uses global var : ...
int CheckOrientation(unsigned char A[] )
{
unsigned int ix, iy; // pixel coordinate
double Zx, Zy; // Z= Zx+ZY*i;
unsigned i; /* index of 1D array */
for(iy=iyMin;iy<=iyMax;++iy)
{
Zy = GiveZy(iy);
for(ix=ixMin;ix<=ixMax;++ix)
{
// from screen to world coordinate
Zx = GiveZx(ix);
i = Give_i(ix, iy); /* compute index of 1D array from indices of 2D array */
if (Zx>0 && Zy>0) A[i]=255-A[i]; // check the orientation of Z-plane by marking first quadrant */
}
}
return 0;
}
// save "A" array to pgm file
int SaveArray2PGMFile( unsigned char A[], double k)
{
FILE * fp;
const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ; it is 8 bit color file */
char name [30]; /* name of file */
sprintf(name,"%f", k); /* */
char *filename =strcat(name,".pgm");
char *comment="# ";/* 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 %u\n %u\n",comment,iWidth,iHeight,MaxColorComponentValue); /*write header to the file*/
fwrite(A,iSize,1,fp); /*write A array to the file in one step */
printf("File %s saved. \n", filename);
fclose(fp);
return 0;
}
int info()
{
// diplay info messages
printf("Numerical approximation of parabolic Julia set for fc(z)= z^2 + c \n");
printf("iPeriodParent = %d \n", iPeriodParent);
printf("iPeriodOfChild = %d \n", iPeriodChild);
printf("parameter c = ( %f ; %f ) \n", Cx, Cy);
printf("alfa fixed point z = ( %f ; %f ) \n", dAlfaX, dAlfaY);
printf("Image Width = %f \n", ZxMax-ZxMin);
printf("PixelWidth = %f \n", PixelWidth);
printf("size of target set in screen units = iMaxDistance2Alfa = %d pixels \n", iMaxDistance2Alfa);
printf("size of target set = dMaxDistance2Alfa = %f [world units] = %f [percent of image width] \n", dMaxDistance2Alfa, dMaxDistance2Alfa/(ZxMax-ZxMin));
printf("iNumberOfUknknown = %d ; it should be 0 ...\n", iNumberOfUknknown);
printf("Maximal number of iterations = iterMax = %ld \n", iterMax);
printf("ratio of image = %f ; it should be 1.000 ...\n", ratio);
return 0;
}
/* ----------------------------------------- main -------------------------------------------------------------*/
int main()
{
setup(iPeriodParent, iPeriodChild);
printf("components of Fatou set : \n");
ComputeFatouComponents(data, iterMax);
SaveArray2PGMFile( data, iWidth+iMaxDistance2Alfa+0.0);
printf("done \n");
ComputeBoundariesIn(data);
SaveArray2PGMFile( edge, iWidth+iMaxDistance2Alfa+0.1);
printf(" Julia set \n");
CopyBoundariesTo(data);
SaveArray2PGMFile( data, iWidth+iMaxDistance2Alfa+0.2);
printf("Julia set and components \n") ;
DrawCriticalOrbit(data, 100000);
SaveArray2PGMFile(data, iWidth+iMaxDistance2Alfa+0.3);
printf(" critical orbit \n");
printf(" allways free memory to avoid buffer overflow \n");
free(data);
free(edge);
info();
return 0;
}
Program output
Run program with :
time ./a.out
output is :
setup i= 0 color = 205 i= 1 color = 165 end of setup components of Fatou set : File 3002.000000.pgm saved. done find boundaries in A array using Sobel filter File 3002.100000.pgm saved. Julia set copy boundaries from edge array to data array File 3002.200000.pgm saved. Julia set and components File 3002.300000.pgm saved. critical orbit allways free memory to avoid buffer overflow Numerical approximation of parabolic Julia set for fc(z)= z^2 + c iPeriodParent = 1 iPeriodOfChild = 2 parameter c = ( -0.750000 ; 0.000000 ) alfa fixed point z = ( -0.500000 ; 0.000000 ) Image Width = 3.000000 PixelWidth = 0.001000 size of target set in screen units = iMaxDistance2Alfa = 1 pixels size of target set = dMaxDistance2Alfa = 0.001000 [world units] = 0.000333 [percent of image width] iNumberOfUknknown = 0 ; it should be 0 ... Maximal number of iterations = iterMax = 10000000 ratio of image = 1.000000 ; it should be 1.000 ... real 29m37.571s user 231m48.189s sys 0m6.818s
Image magic src code
convert a.pgm -resize 1000x1000 a.png
Fragmentarium source code
#include "2D.frag"
#group Julia set
// maximal number of iterations = quality of image
// but also ability to fall into circlae with radius ar
// around alfa fixed point
// if to big then all not escaping points are unknown ( green)
uniform int iMax; slider[1,1000,10000]
// escape radius = er; er2= er*er >= 4.0
uniform float er2; slider[4.0,100.0,1000.0]
// attrating radius (around fixed point alfa) = ar ; ar2 = ar*ar
uniform float ar2; slider[0.000001,0.003,0.03]
//
//uniform float m; slider[0.0,1.0,1000.0]
vec2 c = vec2(-0.75,0.0); // initial value of c
vec2 za = vec2(-0.5,0.0); // alfa fixed point
vec3 GiveColor( int type)
{
switch (type)
{
case 0: return vec3(1.0, 0.0, 0.0); break; //unknown
case 10: return vec3(0.0, 1.0, 0.0); break; // interior right up
case 11: return vec3(0.0, 0.5, 0.0); break; // interior right down
case 20: return vec3(0.0, 0.0, 1.0); break; // interior left up
case 21: return vec3(0.0, 0.0, 0.6); break; // interior left down
case 3: return vec3(1.0, 1.0, 1.0); break; // exterior
default: return vec3(1.0, 0.0,0.0); break;}
}
// compute color of pixel = main function here
vec3 color(vec2 z0) {
vec2 z=z0;
int type=0;
// 0 =unknown; interior right =1; interior left = 2
// exterior =3;
int i=0; // number of iteration
// iteration
for ( i = 0; i < iMax; i++) {
// escape test
if (dot(z,z)> er2) { type = 3; break;}// exterior
// attraction test
if ((dot(z-za,z-za)< ar2) && (i % 2) )
{ if (z.x>za.x) {type = 10;} // interior left
else type=20; // interior right
if (z.y>za.y) type += 1; // up or down
break;
}
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
}
return GiveColor(type);
}
פריטים שמוצגים בקובץ הזה
מוצג
ערך כלשהו ללא פריט ויקינתונים
29 ביולי 2015
image/png
73,726 בית
1,000 פיקסל
1,000 פיקסל
היסטוריית הקובץ
ניתן ללחוץ על תאריך/שעה כדי לראות את הקובץ כפי שנראה באותו זמן.
תאריך/שעה | תמונה ממוזערת | ממדים | משתמש | הערה | |
---|---|---|---|---|---|
נוכחית | 23:03, 31 ביולי 2015 | 1,000 × 1,000 (72 ק"ב) | Soul windsurfer | better quality | |
21:56, 29 ביולי 2015 | 1,000 × 1,000 (67 ק"ב) | Soul windsurfer | User created page with UploadWizard |
שימוש בקובץ
אין בוויקיפדיה דפים המשתמשים בקובץ זה.
שימוש גלובלי בקובץ
אתרי הוויקי השונים הבאים משתמשים בקובץ זה:
- שימוש באתר en.wikibooks.org
מטא־נתונים
קובץ זה מכיל מידע נוסף, שכנראה הגיע ממצלמה דיגיטלית או מסורק שבהם הקובץ נוצר או עבר דיגיטציה.
אם הקובץ שונה ממצבו הראשוני, כמה מהנתונים להלן עלולים שלא לשקף באופן מלא את הקובץ הנוכחי.
הערה בקובץ PNG |
---|