From 7f811848488751390a37e4969552b176fe68d1ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrg=20Lehni?= <juerg@scratchdisk.com>
Date: Sat, 30 Jul 2011 11:38:17 +0100
Subject: [PATCH] Only intersect lines if their lengths are not conflicting
 with Numerical.EPSILON comparison of the cross product in Line#intersect().

---
 src/path/Curve.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/path/Curve.js b/src/path/Curve.js
index a49cf6ae..74b560a0 100644
--- a/src/path/Curve.js
+++ b/src/path/Curve.js
@@ -760,8 +760,15 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
 				return [0.5 * (w[0].x + w[5].x)];
 			// Compute intersection of chord from first control point to last
 			// with x-axis.
-			if (isFlatEnough(w))
-				return [xAxis.intersect(new Line(w[0], w[5], true)).x];
+			if (isFlatEnough(w)) {
+				var line = new Line(w[0], w[5], true);
+				// Compare the line's squared length with EPSILON. If we're
+				// below, #intersect() will return null because of division
+				// by near-zero.
+				return [ line.vector.getLength(true) < Numerical.EPSILON
+						? line.point.x
+						: xAxis.intersect(line).x ];
+			}
 		}
 
 		// Otherwise, solve recursively after