From 54a4fd32ece3165408de9f95280160096a179346 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Fri, 1 Jun 2012 17:12:57 +0300 Subject: added rotation matrices R_U, R_L, R_H --- lsys.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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