2015-12-02 LabN03Tree

posted Dec 2, 2015, 4:53 AM by Samuel Konstantinovich   [ updated Dec 8, 2015, 9:02 PM ]
GOAL: To Tree

Do Now:
Log in
Submit LabN01, LabN02 on the HW server now.

Pay attention to tree explanation + diagrams.

(Diagrams from class are required for these lecture notes, please get notes from other people if you missed class)

You should be able to complete parts 1 and 2 by tomorrow. 

1a. Basic tree (Should be finished at home if you have issues in class)
Write a turtle context function tree n 
-It makes the turtle put it's pen down
-It makes a size n fractal tree. 
-The angle should be constant (it can be a slider)
-The branch size should be constant (it can be a slider also)

1b. Make a slider:
This controls the number of levels of the tree.

1c. Make a go function that asks all turtles to draw a tree of size TREE-SIZE

-There is NO REPEAT command inside the tree command.
-When you define tree you use brackets:
to tree[n]

-When you CALL tree, it is like calling something like fd 3 you don't put brackets:
tree 5
tree x + 1
tree n - 2

2a. Better tree. We will discuss this tomorrow at the start of class, then you have time to work on it 
Write a turtle context function BetterTree n angle branch.

You can still use a slider, but it should be for the STARTING angle and STARTING branch value:
You could have sliders 
you could have a button:    
This would call a function that makes all turtles make the better tree.

*-Multiple parameters are in the same brackets:   to betterTree [n angle branch]
*-Make sure you call BetterTree inside your function, not your old tree.
*-You can change the value of the angle and branch as you use recursion just like  you change n by calling tree n-1.

We will do this tomorrow: (Thursday!)

3: Advanced Tree
3a) Make the branch size decrease every time you call tree.  
3b) Make the angle change (smaller or bigger) every time you call the tree.
*-Example of decaying /random :
      betterTree n - 1 angle + random 3 - random 3 branch * .75
*-Parenthesis are not requred for this but you can use them to help you read the code:
      betterTree (n - 1)  (angle + random 3 - random 3)  (branch * .75)

EXTRA CREDIT Due Monday: Make the coolest looking tree function you can. I will compare them in class and choose the coolest looking ones. (My opinion judges) You can work on them at home, I will give you until Monday. Your goal could be to make a somewhat organic looking tree, or to make a really complex but very viewable tree. Don't just make rainbows... Also don't just copy my Sakura tree with the falling leaves. You can animate this.