Homework 04 solution

$30.00 $24.00

We have already seen in class how to draw a svTree at various recursion levels. In the first part of HW 4, you will be drawing Koch snowflake at a given recursion level. Note that the snowflake is an inverted triangle with each side growing flake recursively. Each side has the circled pattern at various…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Categorys:
Tags:

Description

5/5 – (2 votes)

We have already seen in class how to draw a svTree at various recursion levels. In the first part of HW 4, you will be drawing Koch snowflake at a given recursion level.

Note that the snowflake is an inverted triangle with each side growing flake recursively. Each side has the circled pattern at various recursion levels.

First write a recursive function snowflakeSide(level,length) :

For base case, draw a line of given length. For recursion case, recursively call the function 4 times at level one less, one for flat side, one after turning left 60 degrees, another after turning right 120 degrees and another (after turning left how many degrees ?) to be level with first line.

Now write the non-recursive function snowflake(level, length) that calls snowflakeSide 3 times one for each side of a triangle (turning right 120 degrees 3 times)

NOTE: All these functions do not need to have a return statement.

Have fun with flakes!!

Homework 04 solution
$30.00 $24.00