aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/vec-utils.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-03-06 11:18:30 -0800
committerJose Antonio Marquez2012-03-06 11:18:30 -0800
commit3c4967fa93b3abc529fc404115707307ba72d5cd (patch)
treef3737db979727ee050f8b9c85ef994b0e6ddae27 /js/helper-classes/3D/vec-utils.js
parentbee2df0d4da72677aaa2adae669ffdd4ac210dd6 (diff)
parent84332ab81c1b445195f1d9be8bbeae0725c8e758 (diff)
downloadninja-3c4967fa93b3abc529fc404115707307ba72d5cd.tar.gz
Merge branch 'refs/heads/Ninja-Internal' into FileIO
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