13
$\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$
16
$\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[{
   Opacity@.5,
   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, privacy policy and cookie policy

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