Mathematica分形源码

Mandelbrot分形
Mandelbrot[zc_] := Module[{z = 0, i =0}, While[i < 100 && Abs[z] < 2, z = z^2 + zc; i++]; i];
DensityPlot[Mandelbrot[xc + I yc], {xc, -2,1}, {yc, -1.5, 1.5}, PlotPoints -> 275,
Mesh -> False, Frame -> False, ColorFunction -> (If[# ≠ 1,
Hue[#], Hue[0, 0, 0]] &)];

Spirals:
Show[Graphics[RasterArray[Table[r1 = (x - 1)^2 + y^2; r2 = (x +
1)^2 + y^2; Hue[(Sign[y]ArcCos[(x^2 + y^2 -
1)/Sqrt[r1 r2]] - Log[r1/r2])/(2Pi)], {x, -2, 2, 4/
274}, {y, -2, 2, 4/274}]], AspectRatio -> 1]];

DLA
n = 100; ix = iy = n/2; i = 0; SeedRandom[0]; image = Table[0, {n}, {n}];
Do[{ix, iy} = Floor[n(0.5 + 0.1{Cos[theta], Sin[theta]})] + 1; image[[ix,
iy]] = 1, {theta, 0, 2 Pi, Pi/180}];
While[(ix - n/2)^2 + (iy - n/2)^2 < (n/2)^2, theta = 2 Pi Random[]; {ix, iy} =
Floor[n(1 + {Cos[theta], Sin[theta]})/2]; drift =
True; While[drift, {ix, iy} = Mod[{ix + Random[Integer, {-1, 1}], iy +
Random[Integer, {-1, 1}]}, n]; drift = Plus @@ Flatten[
image[[Mod[ix + {-1,
0, 1}, n] + 1, Mod[iy + {-1, 0, 1}, n] + 1]]] == 0]; image[[ix + 1,
iy + 1]] = 1 - i/n^1.5; i++];
ListDensityPlot[image, Mesh -> False, Frame -> False];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值