Fractal Tree Generator

Thursday, July 05, 2001
By keiji
A simple fractal tree CG.
Using a turtle graphic and recursive functions is relatively an easy way to generate trees or plants in a computer.

Simple Version
This is very simple algorithm like this:

void KwTree_001(K3DTurtle kt,float w,int ct)
  if(ct<0) return;
  float w1=w/4.0, w2=w1*3.;
  kt.Move(w1);    // Draw line only 1/4 length.
  K3DTurtle kt2;
  int i,n=4;
  float a=30, b=360/n;
    kt2=kt; kt2.TurnUp(a);
    // Recursive Call. Change the length slightly by random.

KwTree_001(k3t,w,4);  // Main Call

A little improved version

Used iteration to grow trunk, and used recursion to generate branch.

More Sophisticated Version
I'm planning to use two important characteristics:
  • Both Recursive Call and Iteration to simulate growing.
  • Genetic information and its realization mechanisms to simulate a generation of body.