From 0cb792de93949eb031b01cdd3d6b77d645ed4936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 21 Oct 2015 09:35:40 +0200 Subject: [PATCH] Reverse sign of Line.getSignedDistance() Closes #789 --- src/basic/Line.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/basic/Line.js b/src/basic/Line.js index 7ed66852..196348ac 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -184,11 +184,9 @@ var Line = Base.extend(/** @lends Line# */{ } // Based on the error analysis by @iconexperience outlined in // https://github.com/paperjs/paper.js/issues/799 - return vx === 0 - ? vy >= 0 ? px - x : x - px - : vy === 0 - ? vx >= 0 ? y - py : py - y - : (vx * (y - py) - vy * (x - px)) / Math.sqrt(vx * vx + vy * vy); + return vx === 0 ? vy > 0 ? x - px : px - x + : vy === 0 ? vx < 0 ? y - py : py - y + : ((x-px) * vy - (y-py) * vx) / Math.sqrt(vx * vx + vy * vy); } } });