This exercise introduces several examples of fractal structures, that is, structures where the same pattern is repeated at smaller scales. For these problems, use the turtle graphics functions that you wrote for the last assignment.
Write a function (sierpinski lng n) that draws a Sierpinski gasket with a triangle whose largest side is of length lng and which has a recursion depth of n. The gasket should be drawn from the current position and orientation of the turtle. Note that we do not want to draw the part that is cut out -- only the part that is left. When n = 0, sierpinski should draw an equilateral triangle; otherwise, it should draw nothing, but move to appropriate positions and call itself, three times. Demonstrate that your program can draw a Sierpinski gasket at an arbitrary angle. What is the area of the Sierpinski gasket as n approaches infinity?
replaced by:
Write a program (snowflake lng n) that draws a snowflake curve with a side of length lng and a recursion depth of n, beginning at the existing location and orientation of the turtle. A snowflake with n = 0 would be an equilateral triangle.
A relatively easy way to implement a program to draw the snowflake curve is to think in terms of the turtle walking along the outline and drawing as it moves. You could implement a function (snow-line lng n) that draws a straight line of length lng if n = 0, or calls itself recursively four times otherwise.
Is the area of the snowflake curve bounded in the limit as n approaches infinity? What about the perimeter of the snowflake curve as n approaches infinity?
Write a function (draw-tree lng angle multiple) that draws a tree in this manner. angle should be in degrees. You may define auxiliary functions as desired. Try several parameter values to obtain different trees.
A problem that is encountered in designing computer chips is how to get power to the various parts of the chip while keeping the power lines in a plane. One solution to this problem is to lay out power in a recursive H pattern in which smaller H's are drawn at the tips of each larger H. Use parameters of 90 degrees for angle and (sqrt 0.5) for multiple with your draw-tree function to see how this arrangement covers the plane.