diff -r db6ca177c6c4 -r 0d9ca37901ed geometry.py --- a/geometry.py Tue Jan 23 14:09:52 2018 +0200 +++ b/geometry.py Tue Jan 23 15:30:48 2018 +0200 @@ -442,14 +442,22 @@ a, b = line_1.vertices c, d = line_2.vertices try: - t = (intersection.x - a.x) / (b.x - a.x) + t1 = (intersection.x - a.x) / (b.x - a.x) except ZeroDivisionError: - t = inf + t1 = inf + try: + t2 = (intersection.x - c.x) / (d.x - c.x) + except ZeroDivisionError: + t2 = inf try: - u = (intersection.y - a.y) / (b.y - a.y) + u1 = (intersection.y - a.y) / (b.y - a.y) except ZeroDivisionError: - u = inf - if 0 < t < 1 or 0 < u < 1: + u1 = inf + try: + u2 = (intersection.y - c.y) / (d.y - c.y) + except ZeroDivisionError: + u2 = inf + if (0 < t1 < 1 and 0 < t2 < 1) or (0 < u1 < 1 and 0 < u2 < 1): return intersection else: return None