Archivo:Perturbated Rabbit Julia set.png
De testwiki
Ir a la navegación
Ir a la búsqueda
Tamaño de esta previsualización: 600 × 600 píxeles. Otras resoluciones: 240 × 240 píxeles | 480 × 480 píxeles | 768 × 768 píxeles | 1024 × 1024 píxeles | 2000 × 2000 píxeles.
Archivo original (2000 × 2000 píxeles; tamaño de archivo: 619 kB; tipo MIME: image/png)
Este archivo es de Wikimedia Commons y puede usarse en otros proyectos. La descripción en su página de descripción del archivo se muestra debajo.
Resumen
| DescripciónPerturbated Rabbit Julia set.png | |
| Fecha | |
| Fuente | own work with help of xenodreambuie[3] |
| Autor | Adam majewski |
| Otras versiones |
|
Licencia
Yo, el titular de los derechos de autor de esta obra, la publico en los términos de la siguiente licencia:
Este archivo está disponible bajo la licencia Creative Commons Attribution-Share Alike 4.0 International.
- Eres libre:
- de compartir – de copiar, distribuir y transmitir el trabajo
- de remezclar – de adaptar el trabajo
- Bajo las siguientes condiciones:
- atribución – Debes otorgar el crédito correspondiente, proporcionar un enlace a la licencia e indicar si realizaste algún cambio. Puedes hacerlo de cualquier manera razonable pero no de manera que sugiera que el licenciante te respalda a ti o al uso que hagas del trabajo.
- compartir igual – En caso de mezclar, transformar o modificar este trabajo, deberás distribuir el trabajo resultante bajo la misma licencia o una compatible como el original.
C src code
/*
Adam Majewski
adammaj1 aaattt o2 dot pl // o like oxygen not 0 like zero
console program in c programing language
====================
Rabbits, Basilicas, and Other Julia Sets Wrapped in
Sierpinski CarpetsPaul BlanchardRobert L. DevaneyRobert L. DevaneyShow all 6 authorsElizabeth D. Russell
1.4. A magnification of the doubly inverted rabbit. Note that there are some
“quadruply” inverted copies of the rabbit surrounding this set. These bound regions
that contain critical poi
----------------------------------------------
lambda = 0.0013 − 0.002i
maxima
Maxima 5.41.0 http://maxima.sourceforge.net
(%i3) f:z^2+c +b/(z^2);
(%i4) diff(f,z,1);
(%o4) 2z -2*b/z^3
(%i5)
==============================================
Structure of a program or how to analyze the program
============== Image X ========================
DrawImageOfX -> DrawPointOfX -> ComputeColorOfX
first 2 functions are identical for every X
check only last function = ComputeColorOfX
which computes color of one pixel !
==========================================
---------------------------------
indent d.c
default is gnu style
-------------------
c console progam
export OMP_DISPLAY_ENV="TRUE"
gcc d.c -lm -Wall -march=native -fopenmp
time ./a.out > b.txt
gcc d.c -lm -Wall -march=native -fopenmp
time ./a.out
time ./a.out >a.txt
convert -limit memory 32 -limit map 64 60000.1.pgm -resize 2000x2000 61.png
----------------------
real 0m19,809s
user 2m26,763s
sys 0m0,161s
*/
#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
/* --------------------------------- global variables and consts ------------------------------------------------------------ */
// 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 = 20050; //
// 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 char *edge2;
// 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
static const double ZxMin = -1.35; //-0.05;
static const double ZxMax = 1.35; //0.75;
static const double ZyMin = -1.35; //-0.1;
static const double ZyMax = 1.35; //0.7;
static double PixelWidth; // =(ZxMax-ZxMin)/ixMax;
static double PixelHeight; // =(ZyMax-ZyMin)/iyMax;
static double ratio;
// complex numbers of parametr plane
double complex c; // parameter of function fc(z)=z^2 + c
double complex lambda;
int Period = 2;
static unsigned long int iterMax = 1000000; //iHeight*100;
static double ER = 200.0; // EscapeRadius for bailout test
double EscapeRadius=1000000; // = ER big !!!!
// SAC/J
double lnER; // ln(ER)
int i_skip = 2; // exclude (i_skip+1) elements from average
unsigned char s = 7; // stripe density
double BoundaryWidth = 3.0; // % of image width
double distanceMax; //distanceMax = BoundaryWidth*PixelWidth;
/* colors = shades of gray from 0 to 255 */
unsigned char iColorOfExterior = 250;
unsigned char iColorOfInterior = 200;
unsigned char iColorOfInterior1 = 210;
unsigned char iColorOfInterior2 = 180;
unsigned char iColorOfBoundary = 0;
unsigned char iColorOfUnknown = 30;
/* ------------------------------------------ functions -------------------------------------------------------------*/
//------------------complex numbers -----------------------------------------------------
// from screen to world coordinate ; linear mapping
// uses global cons
double GiveZx ( int ix)
{
return (ZxMin + ix * PixelWidth);
}
// uses globaal cons
double GiveZy (int iy) {
return (ZyMax - iy * PixelHeight);
} // reverse y axis
complex double GiveZ( int ix, int iy){
double Zx = GiveZx(ix);
double Zy = GiveZy(iy);
return Zx + Zy*I;
}
// ****************** DYNAMICS = trap tests ( target sets) ****************************
// bailout test
// z escapes when
// abs(z)> ER or cabs2(z)> ER2
// https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Julia_set#Boolean_Escape_time
int Escapes(complex double z){
// here target set (trap) is the exterior circle with radsius = ER ( EscapeRadius)
// with ceter = origin z= 0
// on the Riemann sphere it is a circle with point at infinity as a center
if (cabs(z)>ER) return 1;
return 0;
}
/* ----------- 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;
}
// ***********************************************************************************************
// ********************** edge detection usung Sobel filter ***************************************
// ***************************************************************************************************
// from Source to Destination
int ComputeBoundaries(unsigned char S[], unsigned char D[])
{
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 D array ( global var )
// clear D array
memset(D, iColorOfExterior, iSize*sizeof(*D)); // for heap-allocated arrays, where N is the number of elements = FillArrayWithColor(D , iColorOfExterior);
// printf(" find boundaries in S array using Sobel filter\n");
#pragma omp parallel for schedule(dynamic) private(i,iY,iX,Gv,Gh,G) shared(iyMax,ixMax)
for(iY=1;iY<iyMax-1;++iY){
for(iX=1;iX<ixMax-1;++iX){
Gv= S[Give_i(iX-1,iY+1)] + 2*S[Give_i(iX,iY+1)] + S[Give_i(iX-1,iY+1)] - S[Give_i(iX-1,iY-1)] - 2*S[Give_i(iX-1,iY)] - S[Give_i(iX+1,iY-1)];
Gh= S[Give_i(iX+1,iY+1)] + 2*S[Give_i(iX+1,iY)] + S[Give_i(iX-1,iY-1)] - S[Give_i(iX+1,iY-1)] - 2*S[Give_i(iX-1,iY)] - S[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) {D[i]=255;} /* background */
else {D[i]=0;} /* boundary */
}
}
return 0;
}
// copy from Source to Destination
int CopyBoundaries(unsigned char S[], unsigned char D[])
{
unsigned int iX,iY; /* indices of 2D virtual array (image) = integer coordinate */
unsigned int i; /* index of 1D array */
//printf("copy boundaries from S array to D array \n");
for(iY=1;iY<iyMax-1;++iY)
for(iX=1;iX<ixMax-1;++iX)
{i= Give_i(iX,iY); if (S[i]==0) D[i]=0;}
return 0;
}
// ***************************************************************************************************************************
// ************************** DEM/J*****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfDEMJ(complex double z){
// https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/Julia_set#DEM.2FJ
int nMax = iterMax;
complex double dz = 1.0; // is first derivative with respect to z.
double distance;
double cabsz;
complex double z2;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > 1e60 || cabs(dz)> 1e60) break; // big values
//if (cabsz< PixelWidth) return iColorOfInterior; // falls into finite attractor = interior
z2 = z*z;
dz = dz*(2*z-2*lambda/(z2*z)) ; // https://fractalforums.org/fractal-mathematics-and-new-theories/28/perturbated-julia-set/3397/;topicseen
z = z2 +c +lambda/z2 ; /* forward iteration : perturbated complex quadratic polynomial */
}
distance = 2.0 * cabsz* log(cabsz)/ cabs(dz);
if (distance <distanceMax) return iColorOfBoundary; // distanceMax = BoundaryWidth*PixelWidth;
// else
return iColorOfExterior;
}
// plots raster point (ix,iy)
int DrawPointOfDEMJ (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfDEMJ(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOfDEMJ (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
//printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfDEMJ(A, ix, iy); //
}
return 0;
}
// ***************************************************************************************************************************
// ************************** Unknown: boundary and slow dynamics *****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfUnknown(complex double z){
int nMax = 20; // very low value
double cabsz;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > 10000000000*ER ) return iColorOfExterior; // big values
if (cabsz < (PixelWidth/100)) return iColorOfInterior; // falls into finite attractor = interior
z = z*z +c ; /* forward iteration : complex quadratic polynomial */
}
//printf("found \n");
return iColorOfUnknown;
}
// plots raster point (ix,iy)
int DrawPointOfUnknown (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfUnknown(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOfUnknown (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
//printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfUnknown(A, ix, iy); //
}
return 0;
}
// ***************************************************************************************************************************
// ************************** BET/J = Binary Escape Tima*****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfBET(complex double z){
int nMax = 255;
double cabsz;
unsigned char iColor;
//double b = 0.001;
complex double z2;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > ER) {return 255;}; // escaping
//if (cabsz< PixelWidth) break; // fails into finite attractor = interior
z2 = z*z;
z = z2 +c +lambda/z2; /* forward iteration : complex quadratic polynomial */
}
iColor = 0; //
return iColor;
}
// plots raster point (ix,iy)
int DrawPointOfBET (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfBET(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOfBET (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfBET(A, ix, iy); //
}
return 0;
}
// ***************************************************************************************************************************
// ************************** LSM/J*****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfLSM(complex double z){
int nMax = 255;
double cabsz;
unsigned char iColor;
//double b = 0.001;
complex double z2;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > ER) break; // esacping
if (cabsz< PixelWidth) break; // fails into finite attractor = interior
z2 = z*z;
z = z2 +c + lambda/z2; /* forward iteration : complex quadratic polynomial */
}
iColor = 255 - 255.0 * ((double) n)/20; // nMax or lower walues in denominator
return iColor;
}
// plots raster point (ix,iy)
int DrawPointOfLSM (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfLSM(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOfLSM (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfLSM(A, ix, iy); //
}
return 0;
}
// ***************************************************************************************************************************
// ************************** binary decomposition BD/J*****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfBD(complex double z){
int nMax = 255;
double cabsz;
unsigned char iColor;
complex double z2;
int n;
for (n=0; n < nMax; n++){ //forward iteration
cabsz = cabs(z);
if (cabsz > ER) break; // esacping
if (cabsz< PixelWidth) break; // fails into finite attractor = interior
z2 = z*z;
z = z2 +c + lambda/z2; /* forward iteration : complex quadratic polynomial */
//z = z*z +c ; /* forward iteration : complex quadratic polynomial */
}
if (creal(z)>0.0)
iColor = 255;
else iColor = 0;
return iColor;
}
// plots raster point (ix,iy)
int DrawPointOfBD (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfBD(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOfBD (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfBD(A, ix, iy); //
}
return 0;
}
// ***************************************************************************************************************************
// ************************** modified binary decomposition BD/J*****************************************
// ****************************************************************************************************************************
unsigned char ComputeColorOfMBD(complex double z){
// const number of iterations
int nMax = 7;
//double cabsz;
unsigned char iColor;
complex double z2;
int n;
for (n=0; n < nMax; n++){ //forward iteration
//cabsz = cabs(z);
//if (cabsz > ER) break; // esacping
//if (cabsz< PixelWidth) break; // falls into finite attractor = interior
z2 = z*z;
z = z2 +c + lambda/z2; /* forward iteration : complex quadratic polynomial */
//z = z*z +c ; /* forward iteration : complex quadratic polynomial */
}
if (cabs(z) > 2.0)
{ // exterior
if (creal(z)>0.0)
iColor = 255;
else iColor = 0;
}
else iColor = iColorOfInterior;
return iColor;
}
// plots raster point (ix,iy)
int DrawPointOfMBD (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfMBD(z);
A[i] = iColor ; // interior
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOMfBD (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
printf (" %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfMBD(A, ix, iy); //
}
return 0;
}
// ***********************************************************************************************
//*************************************** SAC/J **************************************************
// *****************************************************************************************
// https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/stripeAC
// SAC = Stripe Average Coloring
//
// the addend function
// input : complex number z
// output : double number t
double Give_t(double complex z){
return 0.5+0.5*sin(s*carg(z));
}
/*
input :
- complex number
- intege
output = average
*/
double Give_Arg(double complex z , int iMax)
{
int i=0; // iteration
//double complex Z= 0.0; // initial value for iteration Z0
double A = 0.0; // A(n)
double prevA = 0.0; // A(n-1)
double R; // =radius = cabs(Z)
double d; // smooth iteration count
double complex dz = 1.0; // first derivative with respect to z
double de; // Distance Estimation from DEM/J
// iteration = computing the orbit
for(i=0;i<iMax;i++)
{
dz = 2.0 * z * dz ;
z = z*z + c; // https://en.wikibooks.org/wiki/Fractals/Iterations_in_the_complex_plane/qpolynomials
if (i>i_skip) A += Give_t(z); //
R = cabs(z);
// if(R > EscapeRadius) break; // exterior of M set
if (R > 1e60 || cabs(dz)> 1e60) break; // prevent NAN
prevA = A; // save value for interpolation
} // for(i=0
if (i == iMax)
A = -1.0; // interior
else { // exterior
de = 2 * R * log(R) / cabs(dz);
if (de < distanceMax) A = FP_ZERO; // boundary
else {
// computing interpolated average
A /= (i - i_skip) ; // A(n)
prevA /= (i - i_skip - 1) ; // A(n-1)
// smooth iteration count
d = i + 1 + log(lnER/log(R))/M_LN2;
d = d - (int)d; // only fractional part = interpolation coefficient
// linear interpolation
A = d*A + (1.0-d)*prevA;
}
}
return A;
}
unsigned char ComputeColorOfSAC(complex double z){
unsigned char iColor;
double arg;
arg = Give_Arg( z, 2500); // N in wiki
// color is proportional to arg
if (arg < 0.0)
iColor = 0; // interior
else //
{if (arg == FP_ZERO)
iColor = 255; // boundary
else iColor = (unsigned char) (255 - 255*arg );// exterior
}
return iColor;
}
// plots raster point (ix,iy)
int DrawPointOfSAC (unsigned char A[], int ix, int iy)
{
int i; /* index of 1D array */
unsigned char iColor;
complex double z;
i = Give_i (ix, iy); /* compute index of 1D array from indices of 2D array */
z = GiveZ(ix,iy);
iColor = ComputeColorOfSAC(z);
A[i] = iColor ; //
return 0;
}
// fill array
// uses global var : ...
// scanning complex plane
int DrawImagerOMfSAC (unsigned char A[])
{
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(A, ixMax , iyMax)
for (iy = iyMin; iy <= iyMax; ++iy){
printf ("SAC/J : %d from %d \r", iy, iyMax); //info
for (ix = ixMin; ix <= ixMax; ++ix)
DrawPointOfSAC(A, ix, iy); //
}
return 0;
}
// *******************************************************************************************
// ********************************** save A array to pgm file ****************************
// *********************************************************************************************
int SaveArray2PGMFile( unsigned char A[], double k, char* comment )
{
FILE * fp;
const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ; it is 8 bit color file */
char name [100]; /* name of file */
snprintf(name, sizeof name, "%.1f", k); /* */
char *filename =strncat(name,".pgm", 4);
// 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 array with image data bytes to the file in one step
fclose(fp);
// info
printf("File %s saved ", filename);
if (comment == NULL || strlen(comment) ==0)
printf("\n");
else printf (". Comment = %s \n", comment);
return 0;
}
int PrintInfoAboutProgam()
{
// display info messages
printf ("Numerical approximation of Julia set for fc(z)= z^2 + c \n");
//printf ("iPeriodParent = %d \n", iPeriodParent);
//printf ("iPeriodOfChild = %d \n", iPeriodChild);
printf ("parameter c = ( %.16f ; %.16f ) \n", creal(c), cimag(c));
printf ("Image Width = %f in world coordinate\n", ZxMax - ZxMin);
printf ("PixelWidth = %f \n", PixelWidth);
printf("for DEM/J \n");
if ( distanceMax<0.0 || distanceMax > ER ) printf("bad distanceMax\n");
printf("Max distance from exterior to the boundary = distanceMax = %.16f = %f pixels\n", distanceMax, BoundaryWidth);
// image corners in world coordinate
// center and radius
// center and zoom
// GradientRepetition
printf ("Maximal number of iterations = iterMax = %ld \n", iterMax);
printf ("ratio of image = %f ; it should be 1.000 ...\n", ratio);
//
printf("gcc version: %d.%d.%d\n",__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__); // https://stackoverflow.com/questions/20389193/how-do-i-check-my-gcc-c-compiler-version-for-my-eclipse
// OpenMP version is diplayed in the console
return 0;
}
int PrintInfoAboutPoint(complex double z){
//unsigned int ix, iy; // pixel coordinate
// to do
double arg;
unsigned char iColor;
arg = Give_Arg( z, 2500); // N in wiki
iColor = ComputeColorOfSAC(z);
printf ("parameter z = ( %.16f ; %.16f ) \n", creal(z), cimag(z));
printf ("SAC/J : arg = %.16f ; iColor = %d \n", arg, iColor);
return z;
}
// *****************************************************************************
//;;;;;;;;;;;;;;;;;;;;;; setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
// **************************************************************************************
int setup ()
{
printf ("setup start\n");
c = -0.122561166876654 +0.744861766619744*I; // center of period 3 component = Douady rabbit Julia set
lambda = 0.0013 - 0.002*I;
/* 2D array ranges */
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)) / ((double) iWidth / (double) iHeight); // it should be 1.000 ...
//ER2 = ER * ER; // for numerical optimisation in iteration
lnER = log(EscapeRadius); // ln(ER)
/* create dynamic 1D arrays for colors ( shades of gray ) */
data = malloc (iSize * sizeof (unsigned char));
edge = malloc (iSize * sizeof (unsigned char));
edge2 = malloc (iSize * sizeof (unsigned char));
if (data == NULL || edge == NULL || edge2 == NULL){
fprintf (stderr, " Could not allocate memory");
return 1;
}
BoundaryWidth = 0.5 * iWidth/2000.0; // measured in % of image width = it will not change when image width in pixels will change
distanceMax = BoundaryWidth*PixelWidth;
printf (" end of setup \n");
return 0;
} // ;;;;;;;;;;;;;;;;;;;;;;;;; end of the setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
int end(){
printf (" allways free memory (deallocate ) to avoid memory leaks \n"); // https://en.wikipedia.org/wiki/C_dynamic_memory_allocation
free (data);
free(edge);
free(edge2);
PrintInfoAboutProgam();
return 0;
}
// ********************************************************************************************************************
/* ----------------------------------------- main -------------------------------------------------------------*/
// ********************************************************************************************************************
int main () {
setup ();
DrawImagerOfDEMJ(data);
SaveArray2PGMFile (data, iWidth+0.1, "boundary using DEM/J");
DrawImagerOfBD(data);
SaveArray2PGMFile (data, iWidth+0.2, "BD/J");
ComputeBoundaries(data, edge);
SaveArray2PGMFile (edge, iWidth+0.3, "boundaries of BD/J");
DrawImagerOMfBD(data);
SaveArray2PGMFile (data, iWidth+0.4, "MBD/J");
ComputeBoundaries(data, edge2);
SaveArray2PGMFile (edge2, iWidth+0.5, "boundaries of MBD/J");
DrawImagerOfLSM(data);
SaveArray2PGMFile (data, iWidth+0.6, "LSM/J");
ComputeBoundaries(data, edge);
SaveArray2PGMFile (edge, iWidth+0.7, "boundaries of LSM/J");
CopyBoundaries(edge, data);
SaveArray2PGMFile (data, iWidth+0.8, "LSM/J + boundaries");
//DrawImagerOfUnknown(data);
//SaveArray2PGMFile (data, iWidth+0.9, "Unknown : boundary and slow dynamics");
// DrawImagerOMfSAC(data);
//SaveArray2PGMFile (data, iWidth+1.0, "SAC/J + DEM/J");
DrawImagerOfBET (data);
SaveArray2PGMFile (data, iWidth+1.1, "BET");
//PrintInfoAboutPoint(ZxMin+ZyMax*I);
end();
return 0;
}
text output
20050.6.pgm saved . Comment = LSM/J
File 20050.7.pgm saved . Comment = boundaries of LSM/J
File 20050.8.pgm saved . Comment = LSM/J + boundaries
allways free memory (deallocate ) to avoid memory leaks
Numerical approximation of Julia set for fc(z)= z^2 + c
parameter c = ( -0.1225611668766540 ; 0.7448617666197440 )
Image Width = 2.700000 in world coordinate
PixelWidth = 0.000135
for DEM/J
Max distance from exterior to the boundary = distanceMax = 0.0006750336675146 = 5.012500 pixels
Maximal number of iterations = iterMax = 1000000
ratio of image = 1.000000 ; it should be 1.000 ...
gcc version: 7.5.0
ImageMagic src code
convert 20050.1.pgm -resize 2000x2000 35.png
References
- ↑ Rabbits, Basilicas, and Other Julia Sets Wrapped in Sierpinski Carpets by Robert L. Devaney With Paul Blanchard, Antonio Garijo, Sebastian Marotta, and Elizabeth D. Russell
- ↑ wikibooks: DEM/J
- ↑ fractalforums.org: perturbated-julia-set
Leyendas
Añade una explicación corta acerca de lo que representa este archivo
Perturbated Rabbit Julia set. Made with DEM/J
Elementos representados en este archivo
representa a
Algún valor sin elemento de Wikidata
7 abr 2020
image/png
Historial del archivo
Haz clic sobre una fecha y hora para ver el archivo tal como apareció en ese momento.
| Fecha y hora | Miniatura | Dimensiones | Usuario | Comentario | |
|---|---|---|---|---|---|
| actual | 15:18 7 abr 2020 | 2000 × 2000 (619 kB) | wikimediacommons>Soul windsurfer | Uploaded own work with UploadWizard |
Usos del archivo
La siguiente página usa este archivo: