From 4ab6446e16e34b0c9d82ca03f896235669905849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 8 Nov 2014 17:26:13 -0800 Subject: [PATCH] Handle horizontal lines properly in Line.getSignedDistance() Closes #546. --- src/basic/Line.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/basic/Line.js b/src/basic/Line.js index d991dd03..64298abd 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -166,7 +166,8 @@ var Line = Base.extend(/** @lends Line# */{ vx -= px; vy -= py; } - // Cache these values since they're used heavily in fatline code + if (Numerical.isZero(vx)) + return x - px; var m = vy / vx, // slope b = py - m * px; // y offset // Distance to the linear equation