0

I am having trouble creating a Koch curve using the function KochCurve in Mathematica. What I want to create is something like this. enter image description here

However, what I end up with, using this code:

Graphics[KochCurve[2, {0, Pi/2, -Pi/2, -Pi/2, Pi/2}]]

is this enter image description here

As can be seen, the problem is that the triangles in the curve should be squares. How can I fix this problem?

1 Answers1

7

As a workaround you can nest your path and call AnglePath:

n = 7;
angles = {0, π/2, -π/2, -π/2, π/2};

rots = {0, #} & /@ angles;
init = {1, #} & /@ angles;

iters = NestList[Function[s, Partition[Flatten[{#, s} & /@ rots], 2]], init, n - 1];

ListAnimate[Graphics[Line[AnglePath[#]]] & /@ iters]

enter image description here

Greg Hurst
  • 35,921
  • 1
  • 90
  • 136