Skip to content

Commit

Permalink
Fix the problem described in issue apolcyn#7
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kwk1001 authored Feb 8, 2022
1 parent fe54e27 commit c642f24
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion traclus_impl/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down Expand Up @@ -127,4 +129,4 @@ def __ne__(self, other):
def __str__(self):
return "start: " + str(self.start) + ". end: " + str(self.end)



0 comments on commit c642f24

Please sign in to comment.