Koch Snowflake
On this page, you will use recursion to draw the Koch snowflake.
The ch in Koch is like ch in Bach, or the Spanish pronunciation of x in Mexico or Xavier, or the j in Alejandra, or like the Yiddish pronunciation of ch in chutzpah.
The Koch snowflake consists of three copies of the Koch curve, arranged along the sides of a triangle:
Unlike tree
and triangle fractal
, this one does not return the sprite to the same place after each recursive call. It replaces a straight line with a bent line.
The base case is just a line:
At each next level, the algorithm draws four copies of the previous level, each one third the length of the previous level, arranged this way. (The red shows a smaller version of the previous level.)
The red color was added here to make the previous level more visible. Your version should be all one color for now. (You can experiment with color when you are finished.)
"U7L2-KochSnowflake"
-
Complete this recursive procedure to draw one side of the Koch snowflake by filling in the blanks and adding additional blocks as needed.
- When you get one side of the snowflake working, combine three of them to make the entire snowflake.
- Why does the size in each recursive call have to be one third the size of the previous level? There are four copies; why not one fourth the size?
-
These pictures are closely related to the Koch curve. See if you can generate pictures like these by changing the turning angles.