Skip to content

Instantly share code, notes, and snippets.

@butchi
Created December 16, 2015 13:06
Show Gist options
  • Select an option

  • Save butchi/5dc9a5352744dc65bf34 to your computer and use it in GitHub Desktop.

Select an option

Save butchi/5dc9a5352744dc65bf34 to your computer and use it in GitHub Desktop.
コッホ曲線(Mathematicaショートフラクタルシリーズ) ref: http://qiita.com/butchi_y/items/0e1c015f8c3d6955c88b
generator = {0, Pi/3, -Pi/3, 0};
f[list_] := list + # & /@ generator
{
{0, Pi/3, -Pi/3, 0} + 0,
{0, Pi/3, -Pi/3, 0} + Pi/3,
{0, Pi/3, -Pi/3, 0} + -Pi/3,
{0, Pi/3, -Pi/3, 0} + 0
}
inclinationList = Flatten[Nest[f, generator, 5]];
cPoints = Join[{0}, Accumulate[E^(I inclinationList)]];
Graphics[Line[Transpose[{Re[cPoints], Im[cPoints]}]]]
generator = {0, Pi/3, -Pi/3, 0};
f[list_] := list + # & /@ generator
inclinationList = Flatten[Nest[f, generator, 5]];
cPoints = Join[{0}, Accumulate[E^(I inclinationList)]];
Graphics[Line[Transpose[{Re[cPoints], Im[cPoints]}]]]
Graphics@Line@Transpose@{Re[#],Im[#]}&@FoldList[Plus,0,E^(Flatten@Nest[Function[l,l+#&/@{0,Pi/3,-Pi/3,0}],{0},5]I)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment