ジュリア集合を描いてみた(VisualC++ + DirectX で描画)
ジュリア集合集合とは
z_n , I を複素数とする。任意の初期値 z_0 に対して、次の漸化式を定義する。
(1)
但し I は任意の定数。
n -> \infty の極限で、z_n が有限となる(発散しない) z_0 がジュリア集合(Julia set)として知られている。
マンデルブロ集合との違いは、
マンデルブロ集合は任意の定数 I の集合であったのに対して、ジュリア集合初期値 z_0 の集合であるという点である。
z_0 = x + yi (x,yは実数)と表した場合を図示する。

I= -0.37 + -0.612i(-0.64<x<0.64, -0.48<y<0.48)の2次元プロット

拡大図

I= -0.37 + -0.612i(-1.6<x<1.6, -1.2<y<1.2)の2次元プロット

発散時のz_n の 実数部と虚数部の大きさに応じて色分けをした
VisualC++ + DirectX のソース
DirectXの利用の仕方はこちらをご覧ください。
注意:以下のソースには、無駄なインクルードがあります。
/*
Julia集合
*/
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <stdio.h>
#include <direct.h>
#include "DxLib.h"
using namespace std;
double PI = 3.14159265358979323846;
double e = 2.7182818284590452354;
int width = 640;
int height = 480;
//備考:画面サイズはデフォルトで、640×480
complex<double> Z0,Z1,I;
double broad=500; // 拡大率
double x_0=0; // 描画の中心x座標
double y_0=0; // 描画の中心y座標
// プログラムは WinMain から始まります
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
int y =-height/2;
//メインループ
ChangeWindowMode(TRUE);
if( DxLib_Init() == -1 ) return -1 ; // DXライブラリ初期化処理
while(ProcessMessage()==0 && CheckHitKey(KEY_INPUT_ESCAPE)==0){
// ClsDrawScreen();
for(int x = -width/2 ; x <= width/2; x++){
I = complex<double>(-0.37,-0.612);
Z1 = complex<double>(0,0);
Z0 = complex<double>(double(x)/broad-x_0,double(y)/broad-y_0);
int max=0;
for(int n=0; n<=1000; n++){
Z1 = Z0 * Z0 + I;
if(abs(Z1)>1000000) break;
Z0 = Z1;
max++;
}
if(max<1000) {
int r= int(255*pow(e,-double(max)/20.0));
int g= int(255-255*pow(e,-double(Z0.real())/10000.0));
int b= int(255-255*pow(e,-double(Z0.imag())/10000.0));
//printfDx("(%d,%d,%d,%d)\n",x,y,max,g);
DrawPixel( x+ width/2 , y + height/2 , GetColor(r,r,r)) ;
}
}
y++;
if(y>height/2) WaitKey() ;
ScreenFlip();
}
DxLib_End() ; // DXライブラリ使用の終了処理
return 0 ; // ソフトの終了
}
今後の予定
・フラクタル次元の解析を行う(マルチフラクタル解析)。



