~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Hugh Chen~~~~~~~~~~~~

Stochastic, recursive tree. I write the svg file in python - four major steps to implementing the tree, which was basically a bunch of quadrilaterals. First, here's one of the random trees I liked:

Part 8: Stochastic tree with no color.

The first step was to create the basic spiral to form one iterative branch. This was mostly a matter of thinking of alternate ways to iteratively create a single spiral branch. Eventually I settled on using sines and cosines to modulate the x and y coordinates and create triangles as I went. Since I wanted a spiral, naturally I divided by my iterative variable, so I wouldn't just have a circle.

d_width = 3000*(math.cos(2*math.pi*x/100)/math.pow(x,1.5)) d_height = 4000*(math.sin(2*math.pi*x/100)/math.pow(x,1.5))

Here, the coefficients on x inside sin and cosine were determined by the number of spirals I wanted. The coefficient on the sin and cosine as well as the exponent in the denominator were tuned. These determined how to modulate each quadrilateral's two vertices on the ouside of the spiral.

The second step was to ensure that the width of the branch decreased as it went along. This was done using an orthogonal vector to the outside vertices of the branch. This orthogonal vector decided the placement of each quadrilateral's inside vertices as well as the magnitude. Since everything is shrinking due to the super linear denominator, the magnitudes shrank as well.

The third step was to somewhat randomly determine when to recursively sprout a new branch. Since my iterator was capped at 400, I used a binomial variable with a variance and mean related to the recursive call's starting iterator (which increases as the branches get smaller) to determine when the next recursive branch should sprout. Since the mean increases, eventually for the smaller branches, the mean becomes centered farther and farther away and eventually no more branches will sprout.

The fourth step was to actually sprout a recursive branch. Since I was relying on sines and cosines any spirals I made would be axis aligned. Thus, I added a basis into the recursive call such that the spirals would not have to be axis aligned. The basis was calculated off of the vector formed by the bottom two vertices of the quadrilateral sprouting a new branch and it's orthogonal vector. Of course, these vectors were normalized. These basis vectors were used to modulate the changes made to the outside coordinates of the spiral.

x01 = x01 - d_width*x_bx + d_height*y_bx y01 = y01 - d_height*y_by + d_width*x_by

Then, simply to add more randomness, I simply allowed the basis vectors to be negative, each with 50% probability, to allow branches to sprout in different directions. The resulting trees are here:

Part 8: Stochastic tree with no color - Deliverable.
Part 8: Stochastic tree with no color - Deliverable.

For fun, I allowed randomized colors:

Part 8: Stochastic tree with color - Deliverable.
Part 8: Stochastic tree with color - Deliverable.
Part 8: Stochastic tree with color - Deliverable.

A few that came out with hearts, for valentine's day.

Part 8: Stochastic tree with heart - Deliverable.
Part 8: Stochastic tree with heart - Deliverable.

Darker color theme.

Part 8: Stochastic tree with heart - Deliverable.