Sierpinski triangle/Graphical: Difference between revisions

Content deleted Content added
Line 1,255:
Show[Graphics[{Opacity[1], Black, Map[Polygon, Sierpinski[8], 1]}, AspectRatio -> 1]]</lang>
Another faster version
<lang Mathematica>cf = Compile[{{A, _Real, 2}},
With[{a = A[[1]], b = A[[2]], c = A[[3]]},
With[{ab = (a + b)/2, bc = (b + c)/2, ca = (a + c)/2},
{{a, ab, ca}, {ab, b, bc}, {ca, bc, c}}]],
RuntimeAttributes -> {Listable}
];
 
n = 3;
pts = Flatten[Nest[cf, N@{{{0, 0}, {1, 0}, {1/2, √3/2}}}, n], n];
Graphics[Polygon /@ pts]</lang>
 
[[File:MmaSierpinski.png]]