From 60ddc68e56bcf986c02f55bceedfd15acec85b6a Mon Sep 17 00:00:00 2001 From: Jan Date: Mon, 5 Jan 2015 15:16:45 +0100 Subject: [PATCH] Improve Line.getSignedDistance() Improved code is shorter, faster, and should product results with higher precision. --- src/basic/Line.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/basic/Line.js b/src/basic/Line.js index 0962669e..864ba0ab 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -169,8 +169,7 @@ var Line = Base.extend(/** @lends Line# */{ ? vy >= 0 ? px - x : x - px : Numerical.isZero(vy) ? vx >= 0 ? y - py : py - y - : -(vy * x - vx * y - px * (py + vy) + py * (px + vx)) / - Math.sqrt(vx * vx + vy * vy); + : (vx * (y - py) - vy * (x - px)) / Math.sqrt(vx * vx + vy * vy); } } });