diff options
author | Nivesh Rajbhandari | 2012-03-12 16:25:28 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-12 16:25:28 -0700 |
commit | 5fb358d9e80a364d5f300d60b7a9fe0f773741e7 (patch) | |
tree | 2c4d5292b19c91697dffb542f369ec9dcb340f77 /js/helper-classes/3D/vec-utils.js | |
parent | 5f9b67be3b8bdb391d021103c6bcee6be2f6cdf4 (diff) | |
parent | 69d90467865a1384725b2301901be2180c5a841f (diff) | |
download | ninja-5fb358d9e80a364d5f300d60b7a9fe0f773741e7.tar.gz |
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/helper-classes/3D/vec-utils.js')
-rwxr-xr-x | js/helper-classes/3D/vec-utils.js | 16 |
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 | ||