var lsys = 'F' 'F' : 'F-F+FF' iterate2;var tree = lsysprint;console.logtree; // F-F+FF-F-F+FF+F-F+FFF-F+FFvar coords = lsysdrawMathPI / 2; // draw tree with alpha as 90 degreesconsole.logcoords; // [[0,0,0], [0,1,0], [1,1,0], ...
An L-system is a formal grammar defined as an initial axiom string, and a set
of production rules. In the aforementioned example,
F is the initial axiom,
and only one production rule exists:
F -> F-F+FF. The grammar alphabet is
assumed to be all characters with a production rule mapping.
F: draw and move one unit vector forward
-: turn right / left
^: pitch up / down
>: roll right / left
|: reverse vector direction
]: push / pop current tree state
For more info and examples, check out http://yuvadm.github.com/lsys.js