This is a file from the Wikimedia Commons

File:Quadratic Julia set with Internal binary decomposition for internal ray 0.ogv

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Original file(Ogg Theora video file, length 2.8 s, 1,000 × 1,000 pixels, 5.83 Mbps, file size: 1.97 MB)

Summary

Description
English: Quadratic Julia set for complex quadratic polynomial . Exterior of the set has solic colour. Interior of the Julia set is coloured with binary decomposition. Parameter c is changing from nucleus ( c=0), along internal ray 0 to parabolic point ( c= 0.25). Number in the left upper corner is a parameter c.
Date
Source Own work
Author Adam majewski

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
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.

Long description

This video shows dynamical planes for complex quadratic polynomial[1]. Here parameter c is changing along the internal ray of main cardioid of Mandelbrot set[2]. In other words c is changing from 0 to 0.25 ( real number because imaginary part is allways 0 ).

On every image there is filled Julia set with it's interior coloured with internal level sets around fixed point. Here are 3 cases :

  • hyperbolic ( when c= 0.0). Here fixed point is in the center of Julia set
  • attracting ( when 0.0 < c <0.25 ). Here fixed point moves to right
  • parabolic[3]( c= 0.25 ). Here fixed point is on boundary = Julia set.

See how fixed point moves from center of interior to its boundary.

Above video is inspired by these images by T Kawahira

Compare also with :

  • colour video by ?[4]

Algorithm for one image

For every point of z plane do :

  • check if point escapes to infinity under iteration of quadratic polynomial. It is done in GiveExtLastIteration function.
    • if point escapes it is exterior point = is in basin of attraction to infinity
    • if point not escapes it is ( not precisely but ...) interior point so it should be attracted to finite attractor. Check to which part of target set forward iteration of Z goes.
if (Zy>0) return 0; 
    else return 1;

So colour is :

if ( IterationMax != eLastIteration ) {data[i]=245;} /* exterior */
                                 else data[i]= color[GiveIntBinaryDecomposition(Zx, Zy, Cx, Cy, IterationMaxBig, AR2, creal(ZA), cimag(ZA))]; /* interior */

Finite attractor ZA is found using forward iteration of critical point z=0

Target set is a disc around finite attractor ZA with radius AR . It is divided into 2 parts. Because ZA lays on real axis ( imaginary part of ZA = 0) so pne has only to check if zy>0 or not. When finite attractor in on boundary ( not inside Kc) then target set is a petal here ( of flower for other internal rays) not disc ( parabolic case )[5]

Compare with

C source code

This C code creates n pgm files :

double CxMin = 0.000;
double CxMax =  0.25; /* C = Cx + Cy*i */
unsigned int nMax = 22; /* number of steps = number of images */
unsigned int n;
stepCx = (CxMax - CxMin)/ nMax;
for(n=0;Cx<CxMax;++n)
  {
    Cx = CxMin + n* stepCx;
    // create pgm file for Cx
  }
/*
 
  c console program
  -----------------------------------------
  1.ppm file code is  based on the code of Claudio Rocchini
  http://en.wikipedia.org/wiki/Image:Color_complex_plot.jpg
  create 24 bit color graphic file ,  portable pixmap file = PPM 
  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 rgb 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"
 
  -------------------------------------------
  Adam Majewski   fraktal.republika.pl 
 
  Sobel filter 
  Gh = sum of six values ( 3 values of matrix are equal to 0 ). Each value is = pixel_color * filter_coefficients 
 
 
  gcc ilsv.c -lm -Wall -o2
  gcc ilsv.c -lm -Wall -march=native
  time ./a.out
 
 
 
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <string.h>
 
/* iXmax/iYmax = 1 */
unsigned int iXmax = 1000; /* height of image in pixels */
unsigned int iYmax = 1000;
unsigned int iLength; 
/* fc(z) = z*z + c */
#define denominator 1 /* denominator of internal angle */
double CxMin = 0.000;
double CxMax =  0.25; /* C = Cx + Cy*i */
double Cx;
double stepCx;
double Cy =  0.0;
#define AR 0.0014998955  /* PixelWidth*1.5   radius of circle around attractor ZA = target set for attracting points */
#define AR2 AR*AR
//#define alfa (1-sqrt(1-4*Cx))/2 /* attracting or parabolic fixed point z = alfa */
//#define beta (1+sqrt(1-4*Cx))/2 /* repelling or parabolic fixed point z = beta */

/* color */
unsigned char color[]={255,231,123,99}; /* shades of gray used in image */
const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ;  it is 8 bit color file */

 
/* escape time to infinity */
int GiveExtLastIteration(double _Zx0, double _Zy0,double C_x, double C_y, int iMax, double _ER2)
{ 
  int i;
  double Zx, Zy;
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  Zx=_Zx0; /* initial value of orbit  */
  Zy=_Zy0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  for (i=0;i<iMax && ((Zx2+Zy2)<_ER2);i++)
    {
      Zy=2*Zx*Zy + C_y;
      Zx=Zx2-Zy2 +C_x;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
    };
  return i;
}
 
 
/* find attractor ZA  using forward iteration of critical point Z = 0  */
/* if period is >1 gives one point from attracting cycle */
double complex GiveAttractor(double _Cx, double _Cy, double ER2, int _IterationMax)
{
  int Iteration;
  double Zx, Zy; /* z = zx+zy*i */
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  /* -- find attractor ZA  using forward iteration of critical point Z = 0  */
  Zx=0.0;
  Zy=0.0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  for (Iteration=0;Iteration<_IterationMax && ((Zx2+Zy2)<ER2);Iteration++)
    {
      Zy=2*Zx*Zy + _Cy;
      Zx=Zx2-Zy2 + _Cx;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
    };
  return Zx+Zy*I;
}
 

/* to which part of target set z goes */
int GiveIntBinaryDecomposition(double _Zx0, double _Zy0,double C_x, double C_y, int iMax, double _AR2, double _ZAx, double _ZAy )
{ 
  int i;
  double Zx, Zy; /* z = zx+zy*i */
  double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */
  double d, dX, dY; /* distance from z to Alpha  */
  Zx=_Zx0; /* initial value of orbit  */
  Zy=_Zy0;
  Zx2=Zx*Zx;
  Zy2=Zy*Zy;
  dX=Zx-_ZAx;
  dY=Zy-_ZAy;
  d=dX*dX+dY*dY;
  for (i=0;i<iMax && (d>_AR2);i++)
    {
      Zy=2*Zx*Zy + C_y;
      Zx=Zx2-Zy2 +C_x;
      Zx2=Zx*Zx;
      Zy2=Zy*Zy;
      dX=Zx-_ZAx;
      dY=Zy-_ZAy;
      d=dX*dX+dY*dY;
    }
  if (Zy>0) return 0; 
     else return 1;
}

 
/* gives position of point (iX,iY) in 1D array  ; uses also global variables */
unsigned int f(unsigned int _iX, unsigned int _iY)
{return (_iX + (iYmax-_iY-1)*iXmax );}

// save data array to pgm file 
int SavePGMFile(double Cx, unsigned char data[])
{
FILE * fp;
  char name [100]; /* name of file */
  sprintf(name,"%1.9f", Cx); /*  */
  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,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);
  return 0;
}

 
/* --------------------------------------------------------------------------------------------------------- */
 
int main(){
 
 unsigned int nMax = 22; /* number of steps = number of images */
 unsigned int n;
 stepCx = (CxMax - CxMin)/ nMax;
 
  unsigned int iX,iY, /* indices of 2D virtual array (image) = integer coordinate */
    i; /* index of 1D array  */
    iLength = iXmax*iYmax;/* length of array in bytes = number of bytes = number of pixels of image * number of bytes of color */
  /* world ( double) coordinate = dynamic plane = z-plane */
  const double dSide = 1.5;
  const double ZxMin=-dSide;
  const double ZxMax=dSide;
  const double ZyMin=-dSide;
  const double ZyMax=dSide;
  double PixelWidth=(ZxMax-ZxMin)/iXmax;
  double PixelHeight=(ZyMax-ZyMin)/iYmax;
  /* */
  double Zx, Zy;    /* Z=Zx+Zy*i   */
  //double alfa; // define alfa (1-sqrt(1-4*Cx))/2 /* attracting or parabolic fixed point z = alfa */
  double complex ZA;  /* atractor ZA = ZAx + ZAy*i */
  /* */
 
  const double EscapeRadius=2.0; /* radius of circle around origin; its complement is a target set for escaping points */
  double ER2=EscapeRadius*EscapeRadius;
 
  const int IterationMax=60,
    IterationMaxBig= 1000001;
 int eLastIteration;
 
 // iLastIteration;
  //int InternalTile;
  /* sobel filter */
  unsigned char G, Gh, Gv; 
  
 
 
  /* dynamic 1D arrays for colors ( shades of gray ) */
  unsigned char *data, *edge;
  data = malloc( iLength * sizeof(unsigned char) );
  edge = malloc( iLength * sizeof(unsigned char) );
  if (data == NULL || edge==NULL)
    {
      fprintf(stderr," Could not allocate memory");
      getchar(); 
      return 1;
    }
  else printf(" memory is OK\n");
 
 
 
  for(n=0;Cx<CxMax;++n)
   {

   Cx = CxMin + n* stepCx;
   //alfa = (1-sqrt(1-4*Cx))/2 ; /* attracting or parabolic fixed point z = alfa */
 
  ZA = GiveAttractor( Cx, Cy, ER2, IterationMaxBig); /* find attractor ZA  using forward iteration of critical point Z = 0  */
 
 
 
 // printf(" fill the data array \n");
  for(iY=0;iY<iYmax;++iY){ 
    Zy=ZyMin + iY*PixelHeight; /*  */
    if (fabs(Zy)<PixelHeight/2) Zy=0.0; /*  */
   //printf(" row %u from %u \n",iY, iYmax); /* info */   
    for(iX=0;iX<iXmax;++iX){ 
      Zx=ZxMin + iX*PixelWidth;
      eLastIteration = GiveExtLastIteration(Zx, Zy, Cx, Cy, IterationMax, ER2 );
      i= f(iX,iY); /* compute index of 1D array from indices of 2D array */
      if ( IterationMax != eLastIteration ) 
        {data[i]=245;} /* exterior */
      else /* interior */
        { //iLastIteration = GiveIntLastIteration(Zx, Zy, Cx, Cy, IterationMaxBig, AR2, creal(ZA), cimag(ZA));
	  //InternalTile = GiveIntTile( Zx, Zy, Cx, Cy, IterationMaxBig );
         // data[i]=color[iLastIteration % 2];/*  level sets of attraction time */
         data[i]= color[GiveIntBinaryDecomposition(Zx, Zy, Cx, Cy, IterationMaxBig, AR2, creal(ZA), cimag(ZA))];
        //if (Zx>=0 && Zx <= 0.5 && (Zy > 0 ? Zy : -Zy) <= 0.5 - Zx) data[i]=255-data[i]; // show petal

        } 
      /*  if (Zx>0 && Zy>0) data[i]=255-data[i];    check the orientation of Z-plane by marking first quadrant */

    }
  }
 
 
 // printf(" find boundaries in data array using  Sobel filter\n");   
 
  for(iY=1;iY<iYmax-1;++iY){ 
    for(iX=1;iX<iXmax-1;++iX){ 
      Gv= data[f(iX-1,iY+1)] + 2*data[f(iX,iY+1)] + data[f(iX-1,iY+1)] - data[f(iX-1,iY-1)] - 2*data[f(iX-1,iY)] - data[f(iX+1,iY-1)];
      Gh= data[f(iX+1,iY+1)] + 2*data[f(iX+1,iY)] + data[f(iX-1,iY-1)] - data[f(iX+1,iY-1)] - 2*data[f(iX-1,iY)] - data[f(iX-1,iY-1)];
      G = sqrt(Gh*Gh + Gv*Gv);
      i= f(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= f(iX,iY); /* compute index of 1D array from indices of 2D array */
    if (edge[i]==0) data[i]=0;}}
 
 
  /* ---------- file  -------------------------------------*/
  //printf(" save  data array to the file \n");
  SavePGMFile( Cx, data);

  } // for n ....
 
  /* --------------free memory ---------------------*/
  free(data);
  free(edge);
 
 
 
  return 0;
}

Bash source code

#!/bin/bash
 
# script file for BASH 
# which bash
# save this file as g
# chmod +x g
# ./g

# 1000 * 1000 * 33 = 33 MP >12.5 limit
# convert aa33.gif -resize 500x500 aa33s.gif

#time ffmpeg -vcodec {libvpx or vp8} -i input -vsync 0 -an -f null -”. 
#  We all used the latest SVN FFmpeg at the time of this posting; the last revision optimizing the VP8 decoder was r24471.

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 ( Cx from name of file ) using ImageMagic
  convert $file -pointsize 50 -annotate +10+100 $b ${i}.gif
  echo $file
done
 
echo convert all gif files to one animated gif_file
# convert -delay 50   -loop 1 %d.gif[1-$i] aa${i}.gif
# convert -delay 50 -loop 0 %d.gif[1-$i] b${i}.mpg
# convert -delay 50   -loop 1 %d.gif[1-$i] aa${i}.ogv
ffmpeg2theora %d.gif --framerate 12 --videoquality 9  -o output129.ogv

 
echo b${i} OK
# end

References

  1. wikipedia : Complex quadratic polynomial
  2. Internal ray for angle 1/3 of main cardioid of Mandlebrot set
  3. wikibooks : parabolic basin
  4. fractal-surprise-from-complex-function-iteration-the-movie by ?
  5. wikibooks : Parabolic domain

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

19 February 2012

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current08:09, 19 February 20122.8 s, 1,000 × 1,000 (1.97 MB)Soul windsurferbetter quality
08:07, 19 February 20122.8 s, 1,000 × 1,000 (1.29 MB)Soul windsurfer

Global file usage

The following other wikis use this file:

Metadata