## Project 1: Final Iteration

The inspiration of this study is phototropism, which is the way trees grow towards the light source.

Here, I’ve created an algorithm that generates a probability tree. The probability of where the next branch will grow depends if the light source is on the right or left.

Below, the number of iterations, i, is set to 100. Meaning there are 100 branches. The general direction of growth is towards the sun. However, as the direction of the next branch is entirely probabilistic at each junction, the position of every branch is random.

Sun positioned to the right of the tree:

Sun positioned at the left of the tree:

I’ve added an element of interactivity. After i iterations, we call noLoop(). When the mouse is clicked in the window, loop() is called and a new tree at position mouseX will be generated.

For this, i set i = 30 so it won’t be too cluttered

What could’ve been done better?

Currently, the whether the tree grows to the right of left only depends on the x coordinate of the light source. i.e., sun on the right, tree grows to the left.

Imagine a line drawn from the sun to the base of the tree. Let’s call this the source line. I’d like for the branches to converge towards the source line so it looks like it’s growing towards the sun, and eliminate the branches that grow towards the ground.

Also, I would have liked to make the animations smoother. Currently in each frame, 1 branch will be drawn. I’d like for each frame to be a part of a branch, so the process of the branch growing can be seen.