Generate and draw a fractal tree.

 Draw the trunk
 At the end of the trunk, split by some angle and draw two branches
 Repeat at the end of each branch until a sufficient level of branching is reached


Related tasks
 Pythagoras Tree


#include "colors.inc"
#include "transforms.inc"
 
#declare CamLoc = <0, 5, 0>;
#declare CamLook = <0,0,0>;
camera
{
  location CamLoc
  look_at CamLook
  rotate y*90
}
 
light_source
{
  CamLoc
  color White
}
 
#declare Init_Height    = 10;
#declare Spread_Ang     = 35;
#declare Branches       = 14;
#declare Scaling_Factor = 0.75;
 
#macro Stick(P0, P1)
  cylinder { 
    P0, P1, 0.02
    texture { pigment { Green } }
  }
#end
 
#macro FractalTree(O, D, S, R, B)
  #if (B > 0)
    Stick(O, O+D*S)
    FractalTree(O+D*S, vtransform(D, transform{rotate y*R}),
      S*Scaling_Factor, R, B-1)
    FractalTree(O+D*S, vtransform(D, transform{rotate -y*R}),
      S*Scaling_Factor, R, B-1)
  #end
#end
 
union {
  FractalTree(<-2,0,0>, <1,0,0>, 1, Spread_Ang, Branches)
}