Courses‎ > ‎Intro to CS - Full Year‎ > ‎Spring‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

Work 28: 4/12

posted Apr 12, 2019, 10:27 AM by JonAlf Dyrland-Weaver   [ updated Apr 12, 2019, 10:29 AM ]
  • A fractal tree can be drawn as a recursive process. 
  • Consider the function draw_tree(t, branch_levels), it instructs turtle t to draw a tree with bench_depth levels.
    • draw_tree(t, 1)
      • result:
    • draw_tree(t, 2)
      • result: 
    • draw_tree(t, 3)
      • result:
    • draw_tree(t, 4)
      • result:
  • Notice the position and orientation of the turtle when the function is done.
  • Write the recursive draw_tree function and test it.
  • Ask yourself
    • What is the easiest tree to draw
      • What are the instructions for the turtle in that case
    • How many trees are drawn each time you increase the number of branch levels?
  • There are things that you can modify to make your trees look more interesting ONLY LOOK AT THESE IF YOU HAVE THE REGULAR TREE DONE
    • Try out different angles between branches.
      • What if there's some randomness in the angle?
    • Try out different lengths of the branches.
      • What about decreasing or increasing branch sizes for each sub-tree?
submit this as tree