标签:blog http color io sp div on 2014 log
学习Mathematica迭代函数的几个画图例子:
1.三角形沿着某一点旋转
verticse = {{0, 0}, {1, 0}, {1/2, Sqrt[3]/2}}; tri = Line[verticse /. {a_, b__}->{a, b, a}]; Graphics[tri]
rotation[gr_] := Rotate[gr, Pi/13, {1, 1}]; Graphics[NestList[rotation, tri, 30]]
2.绘出迭代平移之后的三角形
translation[gr_] := Translate[gr, verticse]; Graphics[{RGBColor[0.32, 0.77, 1.], NestList[translation, tri, 5]}]
3.Sierpinski Triangle
SierpinskiTriangle[iter_, opts : OptionsPattern[Graphics]] := Module[{vertics, vecs}, vertics = N[{{0, 0}, {1, 0}, {1/2, 1}}]; vecs = 0.5 vertics; Graphics[ {Blue, Nest[{Blue, Translate[Scale[#, 0.5, {0., 0.}], vecs]} &, Polygon[vertics], iter]}, opts]] SierpinskiTriangle[8, ImageSize -> 512]
参考资料:
标签:blog http color io sp div on 2014 log
原文地址:http://www.cnblogs.com/elvalad/p/4052673.html