aboutsummaryrefslogtreecommitdiff
path: root/js/lib/math
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/math')
-rwxr-xr-xjs/lib/math/matrix.js68
1 files changed, 34 insertions, 34 deletions
diff --git a/js/lib/math/matrix.js b/js/lib/math/matrix.js
index 067f83e2..8dee6fdc 100755
--- a/js/lib/math/matrix.js
+++ b/js/lib/math/matrix.js
@@ -33,56 +33,56 @@ var Matrix = function Matrix() {
33}; 33};
34 34
35Matrix.create = function( rowArray ) { 35Matrix.create = function( rowArray ) {
36 var mat = Matrix.I(4); 36 var mat = Matrix.I(4);
37 var index = 0; 37 var index = 0;
38 for(var j=0; j<4; j++) { 38 for(var j=0; j<4; j++) {
39 for (var i=0; i<4; i++) { 39 for (var i=0; i<4; i++) {
40 mat[index] = rowArray[i][j]; 40 mat[index] = rowArray[i][j];
41 index++; 41 index++;
42 } 42 }
43 } 43 }
44 44
45 return mat; 45 return mat;
46}; 46};
47 47
48Matrix.I = function(dimen) { 48Matrix.I = function(dimen) {
49 var mat = []; 49 var mat = [];
50 50
51 for (var i = 0; i<dimen*dimen; i++) { 51 for (var i = 0; i<dimen*dimen; i++) {
52 mat.push(0); 52 mat.push(0);
53 } 53 }
54 54
55 var index = 0; 55 var index = 0;
56 for (var j = 0; j<dimen; j++) { 56 for (var j = 0; j<dimen; j++) {
57 mat[index] = 1.0; 57 mat[index] = 1.0;
58 index += dimen + 1; 58 index += dimen + 1;
59 } 59 }
60 60
61 return mat; 61 return mat;
62}; 62};
63 63
64Matrix.Translation = function (vec) { 64Matrix.Translation = function (vec) {
65 var mat = Matrix.I(4); 65 var mat = Matrix.I(4);
66 glmat4.translate(mat, vec); 66 glmat4.translate(mat, vec);
67 return mat; 67 return mat;
68}; 68};
69 69
70Matrix.RotationX = function( angle ) { 70Matrix.RotationX = function( angle ) {
71 var mat = Matrix.I(4); 71 var mat = Matrix.I(4);
72 glmat4.rotateX(mat, angle); 72 glmat4.rotateX(mat, angle);
73 return mat; 73 return mat;
74}; 74};
75 75
76Matrix.RotationY = function( angle ) { 76Matrix.RotationY = function( angle ) {
77 var mat = Matrix.I(4); 77 var mat = Matrix.I(4);
78 glmat4.rotateY(mat, angle); 78 glmat4.rotateY(mat, angle);
79 return mat; 79 return mat;
80}; 80};
81 81
82Matrix.RotationZ = function( angle ) { 82Matrix.RotationZ = function( angle ) {
83 var mat = Matrix.I(4); 83 var mat = Matrix.I(4);
84 glmat4.rotateZ(mat, angle); 84 glmat4.rotateZ(mat, angle);
85 return mat; 85 return mat;
86}; 86};
87 87
88Matrix.Rotation = function(angle, axis) { 88Matrix.Rotation = function(angle, axis) {
@@ -94,8 +94,8 @@ Matrix.Rotation = function(angle, axis) {
94Matrix.Scale = function( scaleVec ) { 94Matrix.Scale = function( scaleVec ) {
95 var mat = Matrix.I(4); 95 var mat = Matrix.I(4);
96 mat[ 0] = scaleVec[0]; 96 mat[ 0] = scaleVec[0];
97 mat[ 5] = scaleVec[1]; 97 mat[ 5] = scaleVec[1];
98 mat[10] = scaleVec[2]; 98 mat[10] = scaleVec[2];
99 99
100 return mat; 100 return mat;
101}; 101};
@@ -106,7 +106,7 @@ Matrix.flatten = function (mat) {
106 return []; 106 return [];
107 } 107 }
108 108
109 for (var i=0; i<16; i++) { 109 for (var i=0; i<16; i++) {
110 result.push(mat[i]); 110 result.push(mat[i]);
111 } 111 }
112 112