User Rating 0.0
Total Usage 0 times
10
30°
0.70
120px
8
#5B3A29
#4CAF50
#F7F9FC
Is this tool helpful?

Your feedback helps us improve.

About

A binary fractal tree is a recursive geometric structure where each branch spawns exactly two child branches at a specified angle θ. The branch length decreases by a ratio factor r at every recursion level, producing self-similar patterns characteristic of fractal geometry. At depth d the tree contains 2d 1 total segments. Misconfigured parameters produce degenerate or visually collapsed trees. This tool renders the full recursive structure on an HTML5 Canvas with real-time wind simulation and HSL color interpolation from trunk to canopy.

The rendering uses trigonometric endpoint calculation per branch. Wind is modeled as a time-varying sinusoidal perturbation Δθ = A sin(ωt + φdepth) applied per recursion level, creating a natural swaying effect. Depth beyond 15 is capped to prevent rendering > 32,768 branches per frame. The tool approximates organic tree forms under the assumption of uniform branching symmetry.

fractal binary tree recursion generative art math visualization fractal tree canvas

Formulas

Each branch endpoint is computed via polar-to-Cartesian conversion from the parent endpoint. Given a parent tip at (x0, y0) with direction angle α and branch length L:

x1 = x0 + L sin(α)
y1 = y0 L cos(α)

At each recursion level, two child branches are created with angles α θ (left) and α + θ (right), and the new length is scaled:

Lchild = Lparent r

The total number of segments in the tree is a geometric series:

N = dk=0 2k = 2d+1 1

Wind perturbation per level at time t:

Δθ = A sin(ω t + k 0.5)

Where α is the current branch direction angle, θ is the branching spread angle, r is the length ratio (0 < r < 1), d is the maximum recursion depth, A is the wind amplitude, ω is the wind frequency, and k is the current recursion level.

Reference Data

Depth dTotal BranchesTip BranchesLength Ratio r = 0.67Length Ratio r = 0.75Typical Angle θ
111100 px100 px25°
23267 px75 px25°
37444.9 px56.3 px30°
415830.1 px42.2 px30°
5311620.2 px31.6 px30°
6633213.5 px23.7 px35°
7127649.1 px17.8 px35°
82551286.1 px13.3 px25°
95112564.1 px10.0 px25°
101,0235122.7 px7.5 px20°
112,0471,0241.8 px5.6 px20°
124,0952,0481.2 px4.2 px20°
138,1914,0960.8 px3.2 px15°
1416,3838,1920.5 px2.4 px15°
1532,76716,3840.4 px1.8 px15°

Frequently Asked Questions

When the branching angle θ approaches 0°, both child branches overlap the parent direction. The tree degenerates into a single line segment because sin(0) = 0, producing no lateral displacement. Use angles between 15° and 45° for visible branching structure.
Botanical studies suggest ratios near 0.67 to 0.75 approximate real deciduous trees. Leonardo da Vinci observed that the combined cross-sectional area of child branches approximately equals the parent. In this 2D projection, a ratio of r 0.7 with angles of 25° - 35° gives organic results.
At depth d = 15, the tree has 216 1 = 65,535 line segments drawn per frame. At 60 fps with wind animation, this is approximately 3.9 million draw calls per second. Beyond this, most browsers drop below interactive frame rates on integrated GPUs.
When left angle θL right angle θR, the tree loses bilateral symmetry but retains local self-similarity within each subtree. This produces more organic, wind-blown appearances. Extreme asymmetry (e.g., 10° vs 50°) creates spiraling structures resembling fern fronds.
The current model uses a simple sinusoidal perturbation with phase offset per depth level. This approximates laminar swaying but not turbulence. True turbulent simulation would require Perlin noise or a Navier-Stokes approximation per branch, which exceeds real-time budget at high depths. The phase offset φ = k 0.5 creates a convincing wave propagation from trunk to tips.
For a symmetric binary tree with branching ratio r, the fractal (Hausdorff) dimension is D = ln(2) ÷ ln(1 ÷ r). At r = 0.5, D = 1.0 (a line). At r = 0.7, D 1.94, nearly space-filling. At r 1.0 the tree expands infinitely and the fractal dimension is undefined.