diff --git a/basictypes.py b/basictypes.py index 0e049e4..281401d 100644 --- a/basictypes.py +++ b/basictypes.py @@ -64,7 +64,10 @@ class StraightLine: raise WallIDMismatch('Wall ID for points does not match') def __find_line(self, p1:PointWithID, p2:PointWithID) -> tuple: - m = (p2.get_y() - p1.get_y()) / (p2.get_x() - p1.get_x()) + try: + m = (p2.get_y() - p1.get_y()) / (p2.get_x() - p1.get_x()) + except ZeroDivisionError: + m = None # Using p1 to find b b = p1.get_y() - (m*p1.get_x()) # y = mx + b @@ -75,6 +78,9 @@ class StraightLine: if p1.get_wallid() == p2.get_wallid(): return True return False + """ + Return slope for non-virtical line. None for virtical lines + """ def get_m(self)-> float: return self.m