diff options
author | Pushkar Joshi | 2012-03-06 17:04:40 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-03-06 17:04:40 -0800 |
commit | 7a43958033906b2273de88bc2a26cda7a905d202 (patch) | |
tree | f71817e712c4b07a48257a4f0b206cf9033421df /js/helper-classes/3D/vec-utils.js | |
parent | 264e3d8e6d3624083d2fab9fe2560234553bb2ad (diff) | |
parent | 2e3943a8f751ec572066f168b58464c24b9f29e5 (diff) | |
download | ninja-7a43958033906b2273de88bc2a26cda7a905d202.tar.gz |
Merge branch 'master' into brushtool
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 | ||