本帖最后由 chyanog 于 2013-4-28 01:20 编辑
lz的代码是想按照chao game的方法来画吧?- ListPlot@NestList[(# + RandomChoice[{{0, 0}, {1, 0}, {.5, .8}}])/2 &, N@{0, 0}, 10^4]
- (*着色的*)
- With[{data = NestList[(# + RandomChoice@{{0, 0}, {1, 0}, {.5, .8}})/2 &, N@{0, 0}, 10^4]},
- Graphics[Point[data, VertexColors -> ({1, #[[1]], #[[2]]} & /@ Rescale@data)]]]
- (*推广到3D*)
- Module[{v, pts, vc},
- v = {{0, 0, 0.6}, {-0.3, -0.5, -0.2}, {-0.3, 0.5, -0.2}, {0.6, 0, -0.2}};
- pts = NestList[(# + RandomChoice[v])/2 &, N@{0, 0, 0}, 10^4];
- vc = ColorData["Pastel", #] & /@ Rescale@pts[[All, 3]];
- Graphics3D@Point[pts, VertexColors -> vc]
- ]
复制代码 用Polygon的画法,- triangle[{a_, b_, c_}] := {{a, (a + c)/2, (a + b)/2}, {(a + b)/2, b, (b + c)/2}, {(a + c)/2, (b + c)/2, c}};
- d = Nest[Join @@ triangle /@ # &, N@{{{0, 0}, {1, 0}, {.5, .8}}}, 3];
- Graphics[Polygon /@ d]
- (*triangle=Map[Mean,Partition[Tuples[#,2],3],{2}]&;*)
复制代码 |