コンテンツにスキップ

ファイル:Julia set for f(z) = z^4 + z.png

ページのコンテンツが他言語でサポートされていません。

元のファイル (1,000 × 1,000 ピクセル、ファイルサイズ: 13キロバイト、MIME タイプ: image/png)

概要

解説
English: Julia set for f(z) = z^4 + z. It is described in Complex dynamics, Lennart Carleson, Theodore W. Gamelin, Springer, 1993, ISBN 978-0-387-97942-7. Page 40, Figure 2.
原典 投稿者自身による著作物
作者 Adam majewski

C src code

 /* 
 c program:
  1. draws Julia set for z^4-z
  using  boolean escape time )
 -------------------------------         
 2. technic of creating ppm file 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

Adam Majewski
fraktal.republika.pl


(%i1) z:x+y*%i;
(%o1) %i*y+x
(%i2) z1:z^4+z;
(%o2) (%i*y+x)^4+%i*y+x
(%i3) realpart(z1);
(%o3) y^4-6*x^2*y^2+x^4+x
(%i4) imagpart(z1);
(%o4) -4*x*y^3+4*x^3*y+y


gcc z.c -Wall -lm
 
 */
 #include <stdio.h>
#include <stdlib.h> // malloc
#include <math.h>
#include <complex.h>
#include <string.h> // strcat
 
  const int iXmax = 1000; 
 const int iYmax = 1000;
 int iSize ; //= iXmax*iYmax; //
// target set for points falling into alfa fixed point
// is a circle around alfa fixed point
// with radius = AR
double AR ; // radius of target set around alfa fixed point in world coordinate AR = PixelWidth*TargetWidth; 
double AR2; // =AR*AR;
double TargetRadiusInPixels; // radius of target set in pixels ; 

// memmory 1D arrays 
 unsigned char *data;
 unsigned char *edge;
 int i; // index of array
double TwoPi=2.0*M_PI;

/* 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*iYmax; }


 
// save data array to pgm file 
int SaveArray2PGMFile( unsigned char data[], double t)
{
 
  FILE * fp;
  const unsigned int MaxColorComponentValue=255; /* color component is coded from 0 to 255 ;  it is 8 bit color file */
  char name [10]; /* name of file */
  sprintf(name,"%f", t); /*  */
  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,iSize,1,fp);  /*write image data bytes to the file in one step */
  printf("File %s saved. \n", filename);
  fclose(fp);
 
  return 0;
}

double GiveTurn(double complex z)
{
  double argument;
 
  argument = carg(z); //   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
}


unsigned char GiveColorOfInterior(double x, double y)
{
 double angle;
 


// all points tend to z=0 thru 3 petals 
// check to which sector / petal fall 
  angle=GiveTurn(x+y*I); 
  if (angle<1.0/3.0 ) return 235; // ()
  if (angle<2.0/3.0)     return 225; 
 
     return 175; // 9/12 ; 11/12
  
}

int FindBoundaries(unsigned char data[])
{
 
  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; 
 
 
 
 
  printf(" find boundaries in data array using  Sobel filter and save to the edge array \n");   

  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]=245;} /* background */
      else {edge[i]=0;}  /* boundary */
    }
  }
   return 0;
}
 
int CopyBoundaries()
{
 
  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) data[i]=0;}
 
 
 
  return 0;
}




 int main()
 {
 
  /* screen ( integer) coordinate */
  int iX,iY;
 
  
  iSize = iXmax*iYmax; //
 /* world ( double) coordinate = parameter plane*/
 const double xMin=-1.5;
 const double xMax=1.5;
 const double yMin=-1.5;
 const double yMax=1.5;
 /* */
 double PixelWidth=(xMax-xMin)/iXmax;
 double PixelHeight=(yMax-yMin)/iYmax;
 //
 /* color component ( R or G or B) is coded from 0 to 255 */
 /* it is 24 bit color RGB file */
 
 unsigned char color;

//

 double x, y, tempx,    /* Z=x+y*i   */
 x0, y0,  /* Z0 = x0 + y0*i */
 x2, y2; /* x2=x*x;  y2=y*y  */
 double x2y2; //, y4, x4, x2my2;
 /*  */
 int Iteration;
 const int IterationMax=2000;

  
 /* bail-out value , radius of circle ;  */
 const int EscapeRadius=2;
 int ER2=EscapeRadius*EscapeRadius;
 TargetRadiusInPixels = iXmax/100.0; // = 15.0; // radius of target set in pixels ; Maybe increase to 20 = 1000/50
 AR = PixelWidth*TargetRadiusInPixels; // !!!! important value  ( and precision and time of creation of the pgm image ) 
 AR2= AR*AR;

/* create dynamic 1D arrays for colors ( shades of gray ) */
  data = malloc( iSize * sizeof(unsigned char) );
  edge = malloc( iSize * sizeof(unsigned char) );
  if (edge == NULL || edge == NULL )
    {
      fprintf(stderr," Could not allocate memory\n");
      return 1;
    }
  else fprintf(stderr," memory is OK \n");


 

 /* compute and write image data bytes to the file*/
 for(iY=0;iY<iYmax;++iY)
    {
     y0=yMax - iY*PixelHeight; /* reverse Y  axis */
     if (fabs(y0)<PixelHeight/2) y0=0.0; /*  */  
     printf(" iy = %d from %d\r", iY, iYmax); //info   
     for(iX=0;iX<iXmax;++iX)
       {    /* initial value of orbit Z0 */
        x0=xMin + iX*PixelWidth;
        /* Z = Z0 */
       x=x0;
       y=y0;
            
       x2=x*x;
       y2=y*y;
       x2y2= x2+y2;
       /* */
       for (Iteration=0;Iteration<IterationMax ;Iteration++)
          { 
             if ((x2y2)>ER2) { color=255; break;}/* exterior of Filled-in Julia set   */
             if ((x2y2)<AR2) { color=GiveColorOfInterior(x,y); break;}/* interior of Filled-in Julia set   */
             // z^4+z
             tempx =  y*y*y*y -6.0*x*x*y*y +x*x*x*x +x ; // y^4-6*x^2*y^2+x^4+x
             y = -4.0*x*y*y*y + 4.0*x*x*x*y +y; // -4*x*y^3+4*x^3*y+y
	     x=tempx;
             x2=x*x;
             y2=y*y;
	     x2y2= x2+y2;
            
             
             
          };

     if (Iteration==IterationMax) color=GiveColorOfInterior(x,y); ;
     i=Give_i(iX,iY);
     data[i]=color;
                         
    
  
  }
 }
 SaveArray2PGMFile(data,0.101);
FindBoundaries(data);
SaveArray2PGMFile(edge,0.102);
CopyBoundaries();
SaveArray2PGMFile(data,0.103);

//
  free(data);
  free(edge);

 return 0;
 }


ライセンス

この作品の著作権者である私は、この作品を以下のライセンスで提供します。
w:ja:クリエイティブ・コモンズ
表示 継承
このファイルはクリエイティブ・コモンズ 表示-継承 3.0 非移植ライセンスのもとに利用を許諾されています。
あなたは以下の条件に従う場合に限り、自由に
  • 共有 – 本作品を複製、頒布、展示、実演できます。
  • 再構成 – 二次的著作物を作成できます。
あなたの従うべき条件は以下の通りです。
  • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。
  • 継承 – もしあなたがこの作品をリミックスしたり、改変したり、加工した場合には、あなたはあなたの貢献部分を元の作品とこれと同一または互換性があるライセンスの下に頒布しなければなりません。
GNU head この文書は、フリーソフトウェア財団発行のGNUフリー文書利用許諾書 (GNU Free Documentation License) 1.2またはそれ以降のバージョンの規約に基づき、複製や再配布、改変が許可されます。不可変更部分、表紙、背表紙はありません。このライセンスの複製は、GNUフリー文書利用許諾書という章に含まれています。
あなたは上記のライセンスから、どれか一つ以上を選択できます。

キャプション

このファイルの内容を1行で記述してください

このファイルに描写されている項目

題材

ファイルの履歴

過去の版のファイルを表示するには、その版の日時をクリックしてください。

日付と時刻サムネイル寸法利用者コメント
現在の版2013年2月7日 (木) 20:382013年2月7日 (木) 20:38時点における版のサムネイル1,000 × 1,000​(13キロバイト)Soul windsurfer{{Information |Description ={{en|1=Julia set for f(z) = z^5 + z}} |Source ={{own}} |Author =Adam majewski |Date = |Permission = |other_versions = }}

以下のページがこのファイルを使用しています:

グローバルなファイル使用状況

以下に挙げる他のウィキがこの画像を使っています:

メタデータ