summaryrefslogtreecommitdiff
path: root/README.md
blob: dfcf6ed9a50f7618b3fb536cca069e7dc6c2cb47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
L-Systems.JS
============

A full, 3D L-Systems implementation in JavaScript

Usage
-----

```js
var lsys = new LSystem('F', { 'F' : 'F-F+FF' });
var tree = lsys.iterate(2);
console.log(tree);  // F-F+FF-F-F+FF+F-F+FFF-F+FF
```

Definition
------

An L-system is a formal grammar defined as an initial axiom string, and a set
of production rules. In te 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.

Syntax
------

 - `F`: move one unit vector forward
 - `+` / `-`: turn right / left by angle `alpha`
 - `&` / `^`: pitch up / down by angle `alpha`
 - `<` / `>`: roll right / left by angle `alpha`
 - `|`: reverse vector direction
 - `[` / `]`: push / pop current tree state