diff --git a/svgpathtools/path.py b/svgpathtools/path.py index 51378fd..0b5bb49 100644 --- a/svgpathtools/path.py +++ b/svgpathtools/path.py @@ -572,7 +572,7 @@ class Line(object): d = (other_seg.start.imag, other_seg.end.imag) denom = ((a[1] - a[0])*(d[0] - d[1]) - (b[1] - b[0])*(c[0] - c[1])) - if denom == 0: + if np.isclose(denom, 0): return [] t1 = (c[0]*(b[0] - d[1]) - c[1]*(b[0] - d[0]) - diff --git a/test/test_path.py b/test/test_path.py index 3456e82..8474b26 100644 --- a/test/test_path.py +++ b/test/test_path.py @@ -991,6 +991,19 @@ class Test_intersect(unittest.TestCase): self.assertTrue(len(yix), 1) ################################################################### + def test_line_line_0(self): + l0 = Line(start=(25.389999999999997+99.989999999999995j), end=(25.389999999999997+90.484999999999999j)) + l1 = Line(start=(25.390000000000001+84.114999999999995j), end=(25.389999999999997+74.604202137430320j)) + i = l0.intersect(l1) + assert(len(i)) == 0 + + def test_line_line_1(self): + l0 = Line(start=(-124.705378549+327.696674827j), end=(12.4926214511+121.261674827j)) + l1 = Line(start=(-12.4926214511+121.261674827j), end=(124.705378549+327.696674827j)) + i = l0.intersect(l1) + assert(len(i)) == 1 + assert(abs(l0.point(i[0][0])-l1.point(i[0][1])) < 1e-9) + class TestPathTools(unittest.TestCase): # moved from test_pathtools.py