aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
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];