summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lsys.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/lsys.js b/lsys.js
index 1d79dc2..27646c6 100644
--- a/lsys.js
+++ b/lsys.js
@@ -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) {