From c642f243e8a2346cfa64da6e13450ad635733dde Mon Sep 17 00:00:00 2001 From: kwk1001 <68173772+kwk1001@users.noreply.github.com> Date: Tue, 8 Feb 2022 18:16:29 +0800 Subject: [PATCH] Fix the problem described in issue #7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corresponding error: AttributeError: 'LineSegment' object has no attribute 'unit_vector' An incomplete if module causes the problem. It is possible that the value of the variable 'self.length' is 0.0. In that case the attribute ’unit_vector‘ is not defined. --- traclus_impl/geometry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/traclus_impl/geometry.py b/traclus_impl/geometry.py index ee38b2a..7bd9bee 100644 --- a/traclus_impl/geometry.py +++ b/traclus_impl/geometry.py @@ -95,6 +95,8 @@ def __init__(self, start, end): unit_x = (end.x - start.x) / self.length unit_y = (end.y - start.y) / self.length self.unit_vector = Point(unit_x, unit_y) + else: + self.unit_vector = Point(10000000000, 10000000000) def as_dict(self): return {'start': self.start.as_dict(), 'end': self.end.as_dict()} @@ -127,4 +129,4 @@ def __ne__(self, other): def __str__(self): return "start: " + str(self.start) + ". end: " + str(self.end) - \ No newline at end of file +