14
$\begingroup$

Recently, I saw two kinds of animation of Koch curve iteration generation.

enter image description here enter image description here

I don't know how to make this effect, now I can only do this

enter image description here

Clear[koch];
koch[{A_, B_}] := 
  Partition[
    {A, (2 A + B)/3, (A + B)/2 + Cross[B - A]/(2 Sqrt[3]),(A + 2 B)/3, B}, 
    2, 1];
Manipulate[
  Graphics[Line /@ Nest[Join @@ koch /@ # &, N @ {{{-1, 0}, {1, 0}}}, n]], 
  {n, 1, 4, 1}]

Question: How to make animation with transition effect like that?

$\endgroup$

1 Answer 1

18
$\begingroup$

Isn't the fastest but there is not much to see for higher iterations anyway. Let me know if anything is unclear.

Manipulate[
 Graphics[
    Line[
      {#, #2, Dynamic[.5 (#5 + #) + (t + 1 - n) (#3 - .5 (# + #5))], #4, #5}
    ] & @@@ Partition[KochCurve[n][[1]], 5, 4]
  , PlotRange -> {{0, 1}, {0, .3}}
  , ImageSize -> 500
 ],
 {{n, 1}, None},
 {t, 0, 5, .1, TrackingFunction :> ((t = #; n = Ceiling[t]) &)}
]

enter image description here

Manipulate[Graphics[{
   [email protected],
   Line[
      {{#, #2, Dynamic@RotationTransform[-Pi/3. (n - t), #2][#3]},
       {#5, #4, Dynamic@RotationTransform[Pi/3. (n - t), #4][#3]}
      }          
      ] & @@@ Partition[KochCurve[n][[1]], 5, 4]
   }, PlotRange -> {{0, 1}, {0, .3}}, ImageSize -> 500], {{n, 1}, 
  None}, {t, 0, 5, .1, 
  TrackingFunction :> ((t = #; n = Ceiling[t]) &)}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.