渐变分形
来源:互联网 发布:淘宝加微信返现 编辑:程序博客网 时间:2024/06/05 18:38
order = 5;step = 8;next = If[#2 == 0, {#1}, N@{{#1[[1]], 2/3 #1[[1]] + 1/3 #1[[2]]}, {2/3 #1[[1]] + 1/3 #1[[2]], 2/3 #1[[1]] + 1/3 #1[[2]] + Exp[#2 I \[Pi]/3]/3 (#1[[2]] - #1[[1]])}, {1/3 #1[[1]] + 2/3 #1[[2]] + Exp[-#2 I \[Pi]/3]/3 (#1[[1]] - #1[[2]]), 1/3 #1[[1]] + 2/3 #1[[2]]}, {1/3 #1[[1]] + 2/3 #1[[2]], #1[[2]]}}] &;nextstep = next[#, 1] &;node = NestList[ Flatten[nextstep /@ #, 1] &, {{0, 1}, {1, Exp[-I \[Pi]/3]}, {Exp[-I \[Pi]/3], 0}}, order];result = Table[ Flatten[next[#, FractionalPart[k]] & /@ node[[IntegerPart[k]]], 1], {k, 1, order + 1 - 1/step, 1/step}];preplot = Map[{Re[#], Im[#]} &, result, {3}];data = Table[ Graphics[{Blue, Line /@ (preplot[[i]])}, PlotRange -> {{0, 1}, {-Sqrt[3]/2, Sqrt[3]/6}}, ImageSize -> 300], {i, Length@preplot}];data = Flatten[{data, Reverse[data]}, 1];ListAnimate[data, AnimationRate -> 12]
0 0