OverviewUsing 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;
for(i=0;i<n;i++){
kt2=kt; kt2.TurnUp(a);
// Recursive Call. Change the length slightly by random.
KwTree_001(kt2,w2*(1.0+0.05*(rand()%105)),ct1);
kt.RotateRight(b*(i+1));
}
}
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.
]]>