Skip to content

Instantly share code, notes, and snippets.

@butchi
Last active December 15, 2015 21:52
Show Gist options
  • Save butchi/029c3ea62f2c8c65d71e to your computer and use it in GitHub Desktop.
Save butchi/029c3ea62f2c8c65d71e to your computer and use it in GitHub Desktop.
シェルピンスキーのギャスケット(Mathematicaショートフラクタルシリーズ) ref: http://qiita.com/butchi_y/items/fbf5d2b9b49c10c8f217
Graphics@Polygon[Transpose[{Re[#], Im[#]}] & /@
Nest[
Flatten[{#/2, #/2 + 1/4 + Sqrt[3]/4 I, #/2 + 1/2}, 1] &,
{{0, 1/2 + Sqrt[3]/2 I, 1}},
6
]
]
Graphics[Polygon[{Re[#], Im[#]} & /@ {0, 1/2 + Sqrt[3]/2 I, 1}]]
ifs[x_] := {x/2, x/2 + 1/4 + Sqrt[3]/4 I, x/2 + 1/2};
triForce = ifs[{0, 1/2 + Sqrt[3]/2 I, 1}];
Graphics[Polygon[Transpose[{Re[#], Im[#]}] & /@ triForce]]
ifs[x_] := {x/2, x/2 + 1/4 + Sqrt[3]/4 I, x/2 + 1/2};
gasket = Nest[Flatten[ifs[#], 1] &, {{0, 1/2 + Sqrt[3]/2 I, 1}}, 2];
Graphics[Polygon[Transpose[{Re[#], Im[#]}] & /@ gasket]]
Graphics@Polygon[Transpose[{Re[#],Im[#]}]&/@Nest[Flatten[{2#,2#+1+Sqrt[3]I,2#+2}/4,1]&,{{0,2+2Sqrt[3]I,4}/4},6]]
Graphics[Point[{Re[#],Im[#]}&/@Nest[Flatten[{#/2,#/2+1/4+Sqrt[3]/4I,#/2+1/2}]&,0,6]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment