逆写像によるジュリア集合(2)
逆写像によるジュリア集合の描画では、その漸化式において、計算するごとに二つの値を得る、ということを前回見ました。
漸化式で計算結果が2つになるってことは、プログラム的には2分木の再帰処理ということですね。
実際のコードでは Julia クラス内の plot 関数において以下のように記述しました。
private function plot(z:Complex, c:Complex, generation:int):void { // 中略 z = MathComplex.subtract(z, c); z = MathComplex.sqrt(z); var rl:Number = z.real; var im:Number = z.imag; generation--; plot(new Complex( rl, im), c, generation); plot(new Complex(-rl, -im), c, generation); }
2分木処理があったら、4分木処理も試してみたくなるのが人情というもの。
じゃあやってみよう。上のコードを4分木処理にするには、以下のように2行つけ加えるだけですね。
plot(new Complex( rl, im), c, generation); plot(new Complex(-rl, -im), c, generation); plot(new Complex( rl, -im), c, generation); plot(new Complex(-rl, im), c, generation);
するとどうなるのか。結果は↓
逆写像によるジュリア集合の描画(4分木) – wonderfl build flash online
おお、漸化式 c の値を -0.035 + 0.795i にすると、なんか 3D っぽいカンジでなかなかカッコいいじゃねーですか。
Comments
Tell me what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!