aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/vec-utils.js
diff options
context:
space:
mode:
authorhwc4872012-03-06 16:03:26 -0800
committerhwc4872012-03-06 16:03:26 -0800
commit855e8727b147771ff7b05e71bed481e65fe4b6b0 (patch)
tree60d7f091fcf0870495aeaa63748492dbd558619d /js/helper-classes/3D/vec-utils.js
parent1207735f05f202b5bdc5f70c73445f8e0934a227 (diff)
parent4f498b43264327f5886e0370bd3536453d47570a (diff)
downloadninja-855e8727b147771ff7b05e71bed481e65fe4b6b0.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into integration
Conflicts: js/preloader/Preloader.js
Diffstat (limited to 'js/helper-classes/3D/vec-utils.js')
-rwxr-xr-xjs/helper-classes/3D/vec-utils.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js
index ceff4f64..3db95ab7 100755
--- a/js/helper-classes/3D/vec-utils.js
+++ b/js/helper-classes/3D/vec-utils.js
@@ -38,13 +38,13 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
38 if (MathUtils.fpSign(sum) != 0) 38 if (MathUtils.fpSign(sum) != 0)
39 { 39 {
40 var scale = len/sum; 40 var scale = len/sum;
41 rtnVec = Vector.create( [0] ); 41 rtnVec = [0];
42 for (var i=0; i<dimen; i++) 42 for (var i=0; i<dimen; i++)
43 rtnVec[i] = vec[i]*scale; 43 rtnVec[i] = vec[i]*scale;
44 } 44 }
45 else 45 else
46 { 46 {
47 rtnVec = Vector.create( [0] ); 47 rtnVec = [0];
48 for (var i=1; i<dimen; i++) 48 for (var i=1; i<dimen; i++)
49 rtnVec[i] = 0; 49 rtnVec[i] = 0;
50 } 50 }
@@ -67,7 +67,7 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
67 throw new Error( "dimension error in VecUtils.vecAdd" ); 67 throw new Error( "dimension error in VecUtils.vecAdd" );
68 } 68 }
69 69
70 rtnVec = Vector.create([0]); 70 rtnVec = [0];
71 for (var i=0; i<dimen; i++) 71 for (var i=0; i<dimen; i++)
72 rtnVec[i] = a[i] + b[i]; 72 rtnVec[i] = a[i] + b[i];
73 73
@@ -84,7 +84,7 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
84 throw new Error( "dimension error in VecUtils.vecSubtract" ); 84 throw new Error( "dimension error in VecUtils.vecSubtract" );
85 } 85 }
86 86
87 rtnVec = Vector.create([0]); 87 rtnVec = [0];
88 for (var i=0; i<dimen; i++) 88 for (var i=0; i<dimen; i++)
89 rtnVec[i] = a[i] - b[i]; 89 rtnVec[i] = a[i] - b[i];
90 90
@@ -141,11 +141,7 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
141 rtnVal = v0[0]*v1[1] - v0[1]*v1[0]; 141 rtnVal = v0[0]*v1[1] - v0[1]*v1[0];
142 else if (dimen == 3) 142 else if (dimen == 3)
143 { 143 {
144 rtnVal = Vector.create( [ 144 rtnVal = [ v0[1]*v1[2] - v0[2]*v1[1], -v0[0]*v1[2] + v0[2]*v1[0], v0[0]*v1[1] - v0[1]*v1[0] ];
145 v0[1]*v1[2] - v0[2]*v1[1],
146 -v0[0]*v1[2] + v0[2]*v1[0],
147 v0[0]*v1[1] - v0[1]*v1[0]
148 ] );
149 } 145 }
150 else 146 else
151 throw new Error( "VecUtils.vecCross supports only 2 or 3 dimensional vectors: " + dimen ); 147 throw new Error( "VecUtils.vecCross supports only 2 or 3 dimensional vectors: " + dimen );
@@ -162,7 +158,7 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
162 throw new Error( "dimension error in VecUtils.vecSubtract" ); 158 throw new Error( "dimension error in VecUtils.vecSubtract" );
163 } 159 }
164 160
165 var rtnVec = Vector.create([0]); 161 var rtnVec = [0];
166 for (var i=0; i<dimen; i++) 162 for (var i=0; i<dimen; i++)
167 rtnVec[i] = a[i] + t*(b[i] - a[i]); 163 rtnVec[i] = a[i] + t*(b[i] - a[i]);
168 164