From 04a0c995bc63dda5bd8ec0e7720da0426eb69a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 25 Jul 2014 21:01:58 +0200 Subject: [PATCH] Keep Math.acos() argument between -1 and 1. Closes #482. --- src/basic/Point.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index 01a704be..b2c3231d 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -331,7 +331,8 @@ var Point = Base.extend(/** @lends Point# */{ if (Numerical.isZero(div)) { return NaN; } else { - return Math.acos(this.dot(point) / div); + var a = this.dot(point) / div; + return Math.acos(a < -1 ? -1 : a > 1 ? 1 : a); } } },