Results first: Here's your task. Please write a recursive program that creates this output:
(remark: please visualize the snowflake only, not the triangle in the middle, and not the coordinate axes shown in the figure above. I programmed the curve in matlab, that's why the axes are shown).
The snowflake you see developed from the triangle in the center by recursively applying a simple rule
to each of the triangles sides. The Rule, which i deliberately state iteratively here:
- cut the side (of length l) into 3 equal parts (of length l/3)
- replace the center part with 2 sides of length l/3, such that it forms a spike
- repeat the process for each of the 4 sides, until the length of each side is smaller than a given value.
The following figure visualizes this construction rule.
And this is how it looks after being applied twice...
...or applied 7 times:
Finally, if you start with 3 sides (the triangle in figure 1), you'll get the Von Koch Snowflake.
Your task: Compute a von Koch Snowflake RECURSIVELY and display it. In the lab, Nikki will give help on the geometry. A maybe useful geometric hint: the height of the spike is l/sqrt(12), i.e. if you would start with a line defined by the end points [0 0], [1 0], a single application of the construction rule would lead to line segments defined by the following 5 points: [0 0], [1/3 0], [0.5 1/sqrt(12)], [2/3 0], [1 0]. Good luck!