diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2012-06-01 17:12:57 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2012-06-01 17:12:57 +0300 |
| commit | 54a4fd32ece3165408de9f95280160096a179346 (patch) | |
| tree | 560f9a867c249f71bc2c7f0f52cfe9ff9022b424 | |
| parent | b2a3dbd4e0177a50aa1e5f1cdeff8cb786564df4 (diff) | |
added rotation matrices R_U, R_L, R_H
| -rw-r--r-- | lsys.js | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -10,6 +10,33 @@ function LSystem(axiom, rules, draw_constants) { this.tree = axiom; this.draw_constants = draw_constants || []; + this.cos = Math.cos; + this.sin = Math.sin; + + this.R_U = function(a) { + return [ + [cos(a), sin(a), 0], + [-sin(a), cos(a), 0], + [0, 0, 1] + ]; + }; + + this.R_L = function(a) { + return [ + [cos(a), 0, -sin(a)], + [0, 1, 0], + [sin(a), 0, cos(a)] + ]; + }; + + this.R_H = function(a) { + return [ + [1, 0, 0], + [0, cos(a), -sin(a)], + [0, sin(a), cos(a)] + ]; + }; + this.iterate = function(n) { for (var i=0; i<n; i++) { this.tree = this.tree.replace(/\w/g, function(c) { |
