Permalink
Browse files

fixed angle between vector tolerance in vector.js

  • Loading branch information...
Callaghan committed Mar 22, 2011
1 parent 46246db commit 7873c3d4eed4d143d7be5d23e53f38e23d92c3d1
Showing with 8 additions and 1 deletion.
  1. +8 −1 c3dl/math/vector.js
View
@@ -345,5 +345,12 @@ c3dl.isVectorZero = function (vec) {
c3dl.getAngleBetweenVectors = function (vecOne, vecTwo)
{
var dot = c3dl.vectorDotProduct(vecOne, vecTwo);
+ //force dot into acceptable range.
+ if(dot > 1 && dot < 1+c3dl.TOLERANCE) {
+ dot = 1;
+ }
+ else if(dot < -1 && dot > -1-c3dl.TOLERANCE) {
+ dot = -1;
+ }
return c3dl.radiansToDegrees(Math.acos(dot));
-}
+}

0 comments on commit 7873c3d

Please sign in to comment.