aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-09 12:02:27 -0800
committerNivesh Rajbhandari2012-02-09 12:02:27 -0800
commita9b1a1f2642841c4165ede69d131b1deb6238622 (patch)
tree2076dc497fbde041283af8b0082b0f4e24c9e1c6 /js/helper-classes/3D
parent31e2eb0d0da9b032116ad073918ca36ec11dac45 (diff)
parentce81a3f4387d80f9ac406e73b843fb5dbe9cf432 (diff)
downloadninja-a9b1a1f2642841c4165ede69d131b1deb6238622.tar.gz
Merge branch 'refs/heads/ninja-internal' into SnapManagerFixes
Conflicts: js/helper-classes/RDGE/Materials/FlatMaterial.js Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/helper-classes/3D')
-rw-r--r--js/helper-classes/3D/math-utils.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js
index 58f0680a..37044763 100644
--- a/js/helper-classes/3D/math-utils.js
+++ b/js/helper-classes/3D/math-utils.js
@@ -897,19 +897,21 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, {
897 getAxisAngleBetween3DVectors: { 897 getAxisAngleBetween3DVectors: {
898 value: function (vec1, vec2, axis) { 898 value: function (vec1, vec2, axis) {
899 //compute magnitudes of the vectors 899 //compute magnitudes of the vectors
900 var mag1 = VecUtils.vecMag(3, vec1); 900 var v1n = VecUtils.vecNormalize(3, vec1, 1.0);
901 var mag2 = VecUtils.vecMag(3, vec2); 901 var v2n = VecUtils.vecNormalize(3, vec2, 1.0);
902
903 if (mag1 < this.EPSILON || mag2 < this.EPSILON) {
904 return 0; //if angle 0 is returned nothing from this function should be used
905 }
906 //angle between the vectors (acos for now...) 902 //angle between the vectors (acos for now...)
907 var angle = Math.acos(VecUtils.vecDot(3, vec1, vec2) / (mag1 * mag2)); 903 var angle = Math.acos(VecUtils.vecDot(3, v1n, v2n));
908 if (Math.abs(angle) < this.EPSILON) { 904 if (Math.abs(angle) < this.EPSILON) {
909 return 0; 905 return 0;
910 } 906 }
907 //TODO testing...remove this block
908 console.log("getAxisAngleBetween3DVectors Angle: "+angle);
909 if (isNaN(angle)){
910 console.log("getAxisAngleBetween3DVectors Angle is NaN");
911 }
912 //TODO end testing block
911 //optionally, if axis is provided, create the axis of rotation as well 913 //optionally, if axis is provided, create the axis of rotation as well
912 var rotAxis = VecUtils.vecCross(3, vec1, vec2); 914 var rotAxis = VecUtils.vecCross(3, v1n, v2n);
913 rotAxis = VecUtils.vecNormalize(3, rotAxis, 1); 915 rotAxis = VecUtils.vecNormalize(3, rotAxis, 1);
914 axis[0] = rotAxis[0]; 916 axis[0] = rotAxis[0];
915 axis[1] = rotAxis[1]; 917 axis[1] = rotAxis[1];