Family Day update
This commit is contained in:
parent
aac6731f2c
commit
9ad63ea473
2442 changed files with 39761 additions and 8255 deletions
|
|
@ -1,8 +1,6 @@
|
|||
Sierpinski[n_] :=Nest[Flatten[Table[{{
|
||||
#[[i, 1]], (#[[i, 1]] + #[[i, 2]])/2, (#[[i, 1]] + #[[i, 3]])/
|
||||
2}, {(#[[i, 1]] + #[[i, 2]])/2, #[[i,
|
||||
2]], (#[[i, 2]] + #[[i, 3]])/2}, {(#[[i, 1]] + #[[i, 3]])/
|
||||
2, (#[[i, 2]] + #[[i, 3]])/2, #[[i, 3]]}}, {i, Length[#]}],
|
||||
1] &, {{{0, 0}, {1/2, 1}, {1, 0}}}, n]
|
||||
Sierpinski[n_] :=
|
||||
Nest[Join @@ Table[With[{a = #[[i, 1]], b = #[[i, 2]], c = #[[i, 3]]},
|
||||
{{a, (a + b)/2, (c + a)/2}, {(a + b)/2, b, (b + c)/2}, {(c + a)/2, (b + c)/2, c}}],
|
||||
{i, Length[#]}] &, {{{0, 0}, {1/2, 1}, {1, 0}}}, n]
|
||||
|
||||
Show[Graphics[{Opacity[1], Black, Map[Polygon, Sierpinski[8], 1]}, AspectRatio -> 1]]
|
||||
Graphics[{Black, Polygon /@ Sierpinski[8]}]
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
sierpinski[v_, 0] := Polygon@v;
|
||||
sierpinski[v_, n_] := sierpinski[#, n - 1] & /@ (Mean /@ # & /@ v~Tuples~2~Partition~3);
|
||||
Graphics@sierpinski[N@{{0, 0}, {1, 0}, {.5, .8}}, 3]
|
||||
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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue