File:Parabolic rays landing on fixed point.ogv

Original file (file size: 414 KB, MIME type: application/ogg)
![]() | This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionParabolic rays landing on fixed point.ogv |
English: parabolic rays landing on fixed point. One can see sectors around parabolic fixed point |
Source | Own program which uses code by Wolf Jung http://www.mndynamics.com/ |
Author | Adam majewski |
Long Description
This video is related with discrete dynamical system[1] based on complex quadratic polynomial[2] :
This video consist of 40 frames ( see the number of frame in the left upper corner).
Each frame shows part of the dynamic z-plane :
/* world ( double) coordinate = dynamic plane */ const double ZxMin=-2.5; const double ZxMax=2.5; const double ZyMin=-2.5; const double ZyMax=2.5;
On each frame one can see :
- alfa fixed point of function fc : alfa=fc(alfa)
- periodic rays landing on fixed point alfa
Parameter c is different on each frame. It is root point between :
- period 1 component of Mandelbrot set ( main cardioid),
- period n component, here :
unsigned int period ;

This region of parameter plane is a elephant valley[3]
Number of the frame is equal to the period of child component ( parent is 1 ).
Parameter c is on the end ( internal radius = 1.0) of internal ray ( or rotation number) 1/period
denominator = period; InternalAngle = 1.0/((double) denominator); c = GiveC(InternalAngle, 1, 1) ;
In other words it is on boundary of main cardioid
On each fixed point alfa land n=period external rays.
Angle of the external ray landing on fixed point alfa can be computed in a simple way. First denominator d :
d=( (int)pow(2.0,period) -1)
Then angles start from
1/d
and
2*1/d
and so on .
See also : the last page of demo 2 from program Mandel by Wolf Jung [4]
C src code
/*
Adam Majewski
fraktal.republika.pl
c console progam using
* symmetry
* openMP
gcc t.c -lm -Wall -fopenmp -march=native
time ./a.out
iteration max = 10000000
period distance2alfa time
2 0 0m6.633s
3 0 0m10.233s
4 1 0m12.609s
5 3 0m15.866s
6 6 0m18.686s
7 8 0m22.078s
8 11 0m25.080s
9 13 0m27.436s
10 15 0m31.198s
11 17 0m34.510s
12 19 0m37.776s
13 20 0m41.296s
14 21 0m43.475s
15 23 0m48.002s
16 24 0m47.325s
17 25 0m51.179s
*/
#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> // OpenMP; needs also -fopenmp
/* --------------------------------- global variables and consts ------------------------------------------------------------ */
// virtual 2D array and integer ( screen) coordinate
// Indexes of array starts from 0 not 1
unsigned int ix, iy; // var
unsigned int ixMin = 0; // Indexes of array starts from 0 not 1
unsigned int ixMax ; //
unsigned int iWidth ; // horizontal dimension of array
unsigned int ixAxisOfSymmetry ; //
unsigned int iyMin = 0; // Indexes of array starts from 0 not 1
unsigned int iyMax ; //
unsigned int iyAxisOfSymmetry ; //
unsigned int iyAbove ; // var, measured from 1 to (iyAboveAxisLength -1)
unsigned int iyAboveMin = 1 ; //
unsigned int iyAboveMax ; //
unsigned int iyAboveAxisLength ; //
unsigned int iyBelowAxisLength ; //
unsigned int iHeight = 1000; // odd number !!!!!! = (iyMax -iyMin + 1) = iyAboveAxisLength + iyBelowAxisLength +1
// The size of array has to be a positive constant integer
unsigned int iSize ; // = iWidth*iHeight;
// memmory 1D array
unsigned char *data;
// unsigned int i; // var = index of 1D array
unsigned int iMin = 0; // Indexes of array starts from 0 not 1
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 */
const double ZxMin=-2.5;
const double ZxMax=2.5;
const double ZyMin=-2.5;
const double ZyMax=2.5;
double PixelWidth; // =(ZxMax-ZxMin)/ixMax;
double PixelHeight; // =(ZyMax-ZyMin)/iyMax;
double ratio ;
// complex numbers of parametr plane
double Cx; // c =Cx +Cy * i
double Cy;
double complex c; //
double complex alfa; // alfa fixed point alfa=f(alfa)
double complex beta; // beta fixed point alfa=f(alfa)
unsigned long int iterMax = 100; //iHeight*100;
double ER = 2.0; // Escape Radius for bailout test
double ER2;
double AR,AR2; // AR2 = AR*AR where AR is a radius around attractor
/* colors = shades of gray from 0 to 255 */
unsigned char iExterior=245;
unsigned char iInteriorRightUp=231;
unsigned char iInteriorRightDown=99;
unsigned char iInteriorLeftUp=123;
unsigned char iInteriorLeftDown=255;
// {{255,231},{123,99}};
unsigned char iBoundary=0;
/* ------------------------------------------ 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 period)
{
//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 ( period ) // 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 period there are 2^(period-1) roots.
default: // higher periods : 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;
}
double complex GiveBetaFixedPoint(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);
// beta = 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;
}
// distance2 = distance*distance
double GiveDistance2Between(double complex z1, double z2x, double z2y )
{double dx,dy;
dx = creal(z1) - z2x;
dy = cimag(z1) - z2y;
return (dx*dx+dy*dy);
}
int setup(int per)
{
unsigned int denominator;
double InternalAngle;
denominator = per;
InternalAngle = 1.0/((double) denominator);
c = GiveC(InternalAngle, 1, 1) ; // internal radius= o gives center of component
Cx=creal(c);
Cy=cimag(c);
alfa = GiveAlfaFixedPoint(c);
beta = GiveBetaFixedPoint(c);
/* 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].
iyAboveAxisLength = (iHeight -1)/2;
iyAboveMax = iyAboveAxisLength ;
iyBelowAxisLength = iyAboveAxisLength; // the same
iyAxisOfSymmetry = iyMin + iyBelowAxisLength ;
// 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;
AR = PixelHeight; // radius of the target set around fixed attractor
AR2 = AR*AR;
/* create dynamic 1D arrays for colors ( shades of gray ) */
data = malloc( iSize * sizeof(unsigned char) );
if (data == NULL )
{
fprintf(stderr," Could not allocate memory");
getchar();
return 1;
}
return 0;
}
// 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
// forward iteration of complex quadratic polynomial
// fc(z) = z*z +c
// z0 = initial point
// uses global var
/*
Main loop : forward iteration of initial point
*/
unsigned char dGiveColor(double Zx, double Zy, double Cx, double Cy , int iter_max)
{
int i;
double x = Zx, /* Z = x+y*i */
y = Zy,
x2,
y2 ;
x2 = x*x;
y2 = y*y;
if (x2+y2 > ER2) return iExterior; // escapes = exterior
for (i = 1; i <= iter_max; i++)
{
/* z = z*z + c = x+y*i */
y = 2*x*y + Cy;
x = x2 - y2 + Cx;
x2 = x*x;
y2 = y*y;
if (GiveDistance2Between(alfa,x,y)<AR2) break; // interior
if (x2+y2 > ER2) return iExterior; // escapes = exterior
} // for
// if not escapes then z is in a filled Julia set
// interior color : tiling
if (x>creal(alfa))
{if (y>cimag(alfa)) return iInteriorRightUp;
else return iInteriorRightDown;}
else /* x<=creal(alfa) */
if (y>cimag(alfa)) return iInteriorLeftUp;
// last case
return iInteriorLeftDown;
}
unsigned char GiveColor(unsigned int ix, unsigned int iy)
{
double Zx, Zy; // Z= Zx+ZY*i;
unsigned char color; // gray from 0 to 255
// from screen to world coordinate
Zx = GiveZx(ix);
Zy = GiveZy(iy);
color = dGiveColor(Zx, Zy, Cx, Cy ,iterMax);
return color;
}
/* ----------- array functions -------------- */
/* 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 int ix, unsigned int iy, unsigned char iColor)
{
/* i = Give_i(ix,iy) compute index of 1D array from indices of 2D array */
data[Give_i(ix,iy)] = iColor;
return 0;
}
// draws point to memmory array data
// uses complex type so #include <complex.h> and -lm
int dDrawPoint(complex double point,unsigned char iColor, unsigned char data[] )
{
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(ix, iy, iColor);
return 0;
}
/*
http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm
Instead of swaps in the initialisation use error calculation for both directions x and y simultaneously:
*/
void iDrawLine(int x0, int y0, int x1, int y1, int color, unsigned char *array)
{
int x=x0; int y=y0;
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
int err = (dx>dy ? dx : -dy)/2, e2;
for(;;){
iDrawPoint(x, y,color);
if (x==x1 && y==y1) break;
e2 = err;
if (e2 >-dx) { err -= dy; x += sx; }
if (e2 < dy) { err += dx; y += sy; }
}
}
int dDrawLine(double Zx0, double Zy0, double Zx1, double Zy1, int color, unsigned char *array)
{
unsigned int ix0, iy0; // screen coordinate = indices of virtual 2D array
unsigned int ix1, iy1; // screen coordinate = indices of virtual 2D array
// first step of clipping
if ( Zx0 < ZxMax && Zx0 > ZxMin && Zy0 > ZyMin && Zy0 <ZyMax
&& Zx1 < ZxMax && Zx1 > ZxMin && Zy1 > ZyMin && Zy1 <ZyMax )
ix0= (Zx0- ZxMin)/PixelWidth;
iy0 = (ZyMax - Zy0)/PixelHeight; // inverse Y axis
ix1= (Zx1- ZxMin)/PixelWidth;
iy1= (ZyMax - Zy1)/PixelHeight; // inverse Y axis
// second step of clipping
if (ix0 >=ixMin && ix0<=ixMax && ix0 >=ixMin && ix0<=ixMax && iy0 >=iyMin && iy0<=iyMax
&& iy1 >=iyMin && iy1<=iyMax )
iDrawLine(ix0,iy0,ix1,iy1,color,array) ;
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int FillArray(unsigned char data[] )
{
unsigned int ix, iy; // pixel coordinate
// for all pixels of image
for(iy = iyMin; iy<=iyMax; ++iy)
{ printf(" %d z %d\n", iy, iyMax); //info
for(ix= ixMin; ix<=ixMax; ++ix) iDrawPoint(ix, iy, GiveColor(ix, iy) ); //
}
return 0;
}
// fill array using symmetry of image
// uses global var : ...
int FillArraySymmetric(unsigned char data[] )
{
unsigned char Color; // gray from 0 to 255
printf("axis of symmetry \n");
iy = iyAxisOfSymmetry;
#pragma omp parallel for schedule(dynamic) private(ix,Color) shared(ixMin,ixMax, iyAxisOfSymmetry)
for(ix=ixMin;ix<=ixMax;++ix) {//printf(" %d from %d\n", ix, ixMax); //info
iDrawPoint(ix, iy, GiveColor(ix, iy));
}
/*
The use of ‘shared(variable, variable2) specifies that these variables should be shared among all the threads.
The use of ‘private(variable, variable2)’ specifies that these variables should have a seperate instance in each thread.
*/
printf("symmetric parts :\n");
#pragma omp parallel for schedule(dynamic) private(iyAbove,ix,iy,Color) shared(iyAboveMin, iyAboveMax,ixMin,ixMax, iyAxisOfSymmetry)
// above and below axis
for(iyAbove = iyAboveMin; iyAbove<=iyAboveMax; ++iyAbove)
{printf("%d from %d\r", iyAbove, iyAboveMax); //info
for(ix=ixMin; ix<=ixMax; ++ix)
{ // above axis compute color and save it to the array
iy = iyAxisOfSymmetry + iyAbove;
Color = GiveColor(ix, iy);
iDrawPoint(ix, iy, Color );
// below the axis only copy Color the same as above without computing it
iDrawPoint(ixMax-ix, iyAxisOfSymmetry - iyAbove , Color );
}
}
printf("\ndone\n");
return 0;
}
int AddEdges(unsigned char data[] )
{
// memmory 1D array
unsigned char *edge;
/* sobel filter */
unsigned char G, Gh, Gv;
unsigned int i; /* index of 1D array */
printf("find boundaries in data array using Sobel filter : ");
/* create dynamic 1D arrays for colors ( shades of gray ) */
edge = malloc( iSize * sizeof(unsigned char) );
if (edge==NULL)
{
fprintf(stderr," Could not allocate memory for the edge array.Stop the program. \n");
return 1;
}
for(iy=1;iy<iyMax-1;++iy){
for(ix=1;ix<ixMax-1;++ix){
Gv= data[Give_i(ix-1,iy+1)] + 2*data[Give_i(ix,iy+1)] + data[Give_i(ix-1,iy+1)] - data[Give_i(ix-1,iy-1)] - 2*data[Give_i(ix-1,iy)] - data[Give_i(ix+1,iy-1)];
Gh= data[Give_i(ix+1,iy+1)] + 2*data[Give_i(ix+1,iy)] + data[Give_i(ix-1,iy-1)] - data[Give_i(ix+1,iy-1)] - 2*data[Give_i(ix-1,iy)] - data[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 */
}
}
//printf(" copy boundaries from edge to data array \n");
for(iy=1;iy<iyMax-1;++iy){
for(ix=1;ix<ixMax-1;++ix)
{i= Give_i(ix,iy); /* compute index of 1D array from indices of 2D array */
if (edge[i]==0) data[i]=0;}}
free(edge);
printf(" done\n");
return 0;
}
// Check Orientation of image : mark first quadrant
// it should be in the upper right position
// uses global var : ...
int CheckOrientation(unsigned char data[] )
{
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) data[i]=255-data[i]; // check the orientation of Z-plane by marking first quadrant */
}
}
return 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 complex z)
{
double x = creal(z);
double y = cimag(z);
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;
}
double complex preimage(double complex z1, double complex z2, double complex c)
{
double complex zPrev;
zPrev = root(creal(z1) - creal(c) + ( cimag(z1) - cimag(c))*I);
// choose one of 2 roots
if (creal(zPrev)*creal(z2) + cimag(zPrev)*cimag(z2) > 0)
return zPrev ; // u+v*i
else return -zPrev; // -u-v*i
}
// This function only works for periodic or preperiodic angles.
// You must determine the period n and the preperiod k before calling this function.
// draws all "period" external rays
double complex DrawRay(double t0, // external angle in turns
int n, //period of ray's angle under doubling map
int k, // preperiod
int iterMax,
double complex c
)
{
double xNew; // new point of the ray
double yNew;
double xend ; // re of the endpoint of the ray
double yend; // im of the endpoint of the ray
const double R = 100; // very big radius = near infinity
int j; // number of ray
int iter; // index of backward iteration
double t=t0;
double complex zPrev;
double u,v; // zPrev = u+v*I
double complex zNext;
printf(" preperiod = %d \n" , k);
/* dynamic 1D arrays for coordinates ( x, y) of points with the same R on preperiodic and periodic rays */
double *RayXs, *RayYs;
int iLength = n+k+2; // length of arrays ?? why +2
// creates arrays : RayXs and RayYs and checks if it was done
RayXs = malloc( iLength * sizeof(double) );
RayYs = malloc( iLength * sizeof(double) );
if (RayXs == NULL || RayYs==NULL)
{
fprintf(stderr,"Could not allocate memory");
getchar();
return 1; // error
}
// starting points on preperiodic and periodic rays
// with angles t, 2t, 4t... and the same radius R
for (j = 0; j < n + k; j++)
{ // z= R*exp(2*Pi*t)
RayXs[j] = R*cos((2*M_PI)*t);
RayYs[j] = R*sin((2*M_PI)*t);
t *= 2; // t = 2*t
if (t > 1) t--; // t = t modulo 1
}
zNext = RayXs[0] + RayYs[0] *I;
// printf("RayXs[0] = %f \n", RayXs[0]);
// printf("RayYs[0] = %f \n", RayYs[0]);
// z[k] is n-periodic. So it can be defined here explicitly as well.
RayXs[n+k] = RayXs[k];
RayYs[n+k] = RayYs[k];
// backward iteration of each point z
for (iter = -10; iter <= iterMax; iter++)
{
for (j = 0; j < n+k; j++) // period +preperiod
{ // u+v*i = sqrt(z-c) backward iteration in fc plane
zPrev = root(RayXs[j+1] - creal(c)+(RayYs[j+1] - cimag(c))*I ); // , u, v
u=creal(zPrev);
v=cimag(zPrev);
// choose one of 2 roots: u+v*i or -u-v*i
if (u*RayXs[j] + v*RayYs[j] > 0)
{ xNew = u; yNew = v; } // u+v*i
else { xNew = -u; yNew = -v; } // -u-v*i
//
dDrawLine(xNew, yNew, RayXs[j], RayYs[j], 255, data);
RayXs[j] = xNew; RayYs[j] = yNew;
} // for j ...
//RayYs[n+k] cannot be constructed as a preimage of RayYs[n+k+1]
RayXs[n+k] = RayXs[k];
RayYs[n+k] = RayYs[k];
// convert to pixel coordinates
// if z is in window then draw a line from (I,K) to (u,v) = part of ray
// printf("for iter = %d cabs(z) = %f \n", iter, cabs(RayXs[0] + RayYs[0]*I));
}
// aproximate end of ray by straight line to its landing point here = alfa fixed point
for (j = 0; j < n + 1; j++)
dDrawLine(RayXs[j],RayYs[j], creal(alfa), cimag(alfa), 255, data);
// last point of a ray 0
xend = RayXs[0];
yend = RayYs[0];
printf("landing point of ray for angle = %f is = %f ; %f \n",t0, RayXs[0], RayYs[0]);
// free memmory
free(RayXs);
free(RayYs);
return xend + yend*I; // return last point or ray for angle t
}
// save data array to pgm file
int SaveArray2PGMFile( unsigned char data[], int 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,"%d", 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(data,iSize,1,fp); /*write image data bytes to the file in one step */
printf("File %s saved. \n", filename);
fclose(fp);
return 0;
}
int info()
{
// diplay info messages
printf("Cx = %f \n", Cx);
printf("Cy = %f \n", Cy);
//
printf("alfax = %f \n", creal(alfa));
printf("alfay = %f \n", cimag(alfa));
printf("betax = %f \n", creal(beta));
printf("betay = %f \n", cimag(beta));
printf("target set around fixed attractor has radius AR = %f = %f pixels wide \n", AR, AR/PixelWidth);
printf("ratio of image = %f ; it should be 1.000 ...\n", ratio);
return 0;
}
double GiveAngleInTurns(int numerator, int denominator)
{
printf("draw ray for angle = %d / %d ; " , numerator, denominator);
return ((double)(numerator % denominator))/((double)denominator);}
/* ----------------------------------------- main -------------------------------------------------------------*/
int main()
{
unsigned int period ; // period of secondary component joined by root point
int preperiod=0; // preperiod
// external angle of dynamic ray in turns
int n=1; // numerator of angle
// denominator of angle
int d; //=( (int)pow(2.0,period) -1) * (int)pow(2.0,preperiod); // http://fraktal.republika.pl/mset_external_ray_m.html
double complex LastPointOfRay;
double dx,dy;
for (period=2; period<41; ++period)
{
d=( (int)pow(2.0,period) -1) * (int)pow(2.0,preperiod); // http://fraktal.republika.pl/mset_external_ray_m.html
setup(period);
// here are procedures for creating image file
// compute colors of pixels = image
//FillArray( data ); // no symmetry
//FillArraySymmetric(data);
//AddEdges(data);
// CheckOrientation( data );
// external rays for fixed point and its preimages
// preperiod k=0 ; period 2 = two rays
LastPointOfRay = DrawRay(GiveAngleInTurns(1,d) ,period, 0, 10000000,c);
dx=creal(LastPointOfRay)-creal(alfa);
dy=cimag(LastPointOfRay)-cimag(alfa);
d=sqrt(dx*dx+dy*dy )/PixelWidth;
printf("distance to alfa = %d pixels \n", (int)d );
SaveArray2PGMFile( data,period); // save array (image) to pgm file
}
free(data);
//info();
return 0;
}
Bash src code
#!/bin/bash
# script file for BASH using ImageMagic
# http://www.imagemagick.org/script/command-line-options.php
# which bash
# save this file as g
# chmod +x g
# ./g
i=0
# for all pgm files in this directory
for file in *.pgm ; do
# b is name of file without extension
b=$(basename $file .pgm)
# change file name to integers and count files
((i= i+1))
# convert from pgm to gif and add text ( level ) using ImageMagic
convert $file -pointsize 50 -stroke white -fill white -annotate +10+100 $b $b.gif
echo $file $b
done
echo convert all gif files to one video file
# ffmpeg2theora %d.gif --framerate 5 --videoquality 9 -f webm --artist "Adam Majewski" -o o${i}.webm
ffmpeg2theora %d.gif[2-40] --framerate 3 --videoquality 10 -f ogv --artist "Adam Majewski" -o o${i}.ogv
# convert -delay 100 -loop 0 %d.gif[2-40] a40.gif
echo o${i} OK
# end
References
- ↑ wikipedia : Dynamical system
- ↑ w:Complex quadratic polynomial
- ↑ Visual Guide To Patterns In The Mandelbrot Set by Miqel. Archived from the original on 2013-05-31. Retrieved on 2013-06-18.
- ↑ Mandel: software for real and complex dynamics by Wolf Jung
Licensing



- 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.
![]() |
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 |
Captions
Items portrayed in this file
depicts
some value
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 21:49, 14 June 2013 | ![]() | (414 KB) | wikimediacommons>Soul windsurfer | {{Information |Description ={{en|1=parabolic rays landing on fixed point}} |Source ={{own}} |Author =Adam majewski |Date = |Permission = |other_versions = }} |
File usage
The following page uses this file: