Random Tree Generator

This is a simple random tree generator made in attempt to study the degrees of freedom in the appearance of a tree. I wanted to see what kind of branch length, mass splitting and separation angles would generate realistic trees. In the above, I have assumed perfectly cylindrical branches. If a branch with length $L$, diameter $D$ and direction $\mathbf{d}$ is to split into two new branches (subscripted by 1 and 2) I have assumed the following:

Bisection matching at branching point

Since matrials are carried along the surface of the tree, it seems reasonable to match the length of the boundaries to conserve any flux passing through. That amounts to saying that \[ D = D_1 + D_2, \] where $D$ is the diameter of the parent branch, and $D_1$ and $D_2$ the diameter of the two child branches. Therefore, the thickness at a branching point is determined by a random variable $f\in[0,1]$ that results in $D_1 = fD$ and $D_2 = (1-f)D$. Note, however, that is important to impose independence of index swapping. If a certain tree has a mean mass splitting factor of $\langle f \rangle \simeq 0.9$, then that factor counts equally on both the left and right branch. A nice way to impose this is to randomly pick a permutation of the two indices.

Branching should respect center of mass

If a tree branches too much off to one side, it would tip over. And trees that tip over are bad trees. To prevent bad trees, the new branches should try to respect the direction of their parent branch. Since we are considering 2D trees, we can think of the directions $\mathbf{d}$, $\mathbf{d}_1$ and $\mathbf{d}_2$ as points on the complex unit circle. To keep things simple, let us place the real axis along $\mathbf{d}$ and write $\mathbf{d}_1 = e^{i(\theta_0+\delta \theta)}$ and $\mathbf{d}_2 = e^{i(\theta_0-\delta \theta)}$. Then, assuming constant density, we reach the constraint \[ \Im \left[ M_1 L_1 e^{i\theta_0+i\delta\theta} + M_2 L_2 e^{i\theta_0-i\delta\theta} \right] \simeq 0. \implies tan(\theta_0) = \frac{M_2 L_2 - M_1 L_1}{M_2L_2 + M_1 L_1}tan(\delta \theta), \] where $M_i$ for $i=1,2$ refers to the mass of each child branch. Since the mass density $M_i$ scales with the volume of the branch, we have $M_i \propto D_i^2 L_i$, so that the constraint can be written \[ tan(\theta_0) = \frac{L_2^2 D_2^2 - L_1^2 D_1^2}{L_2^2 D_2^2 + L_1^2 D_1^2}tan(\delta \theta). \]

Thin branches have shorter lengths

As a branch grows, there is a certain likelihood that the branch will break. As new branches form, these will also reduce the sunlight on the branch. Therefore, it is reasonable to expect the older parts of the tree to have less branchings. In absence of a better model, it seems reasonable to impose some scaling law $L \sim D^\gamma$. Let us, for simplicity, assume this to be a clean proportionality. Then we need $\gamma > 0$ because $L$ has to vanish with $D$, and (at least the mean) $\gamma \lesssim 1$ since $L$ should be smaller than the $L$ of the previous branch. That is \[ L_n = \left(\frac{D_n}{D}\right)^\gamma L. \] The result of these three constraints is what can be observed in the animation above. Pressing SPACE generates a new tree from a statistical distribution of parameters $(f,\delta \theta, \gamma)$. Change values in the slider and press SPACE to sample from a custom distribution. Have fun!