diff --git a/pycam/Geometry/Line.py b/pycam/Geometry/Line.py index c0f1572e..92222bdd 100644 --- a/pycam/Geometry/Line.py +++ b/pycam/Geometry/Line.py @@ -189,9 +189,9 @@ def get_intersection(self, line, infinite_lines=False): return None, None # the lines are on one straight candidates = [] - if self.is_point_inside(x3): + if self.is_point_inside(x3) and pnorm(a) != 0: candidates.append((x3, pnorm(c) / pnorm(a))) - elif self.is_point_inside(x4): + elif self.is_point_inside(x4) and pnorm(a) != 0: candidates.append((x4, pdist(line.p2, self.p1) / pnorm(a))) elif line.is_point_inside(x1): candidates.append((x1, 0)) diff --git a/pycam/Geometry/PointUtils.py b/pycam/Geometry/PointUtils.py index 234afd23..7b59d8fd 100644 --- a/pycam/Geometry/PointUtils.py +++ b/pycam/Geometry/PointUtils.py @@ -76,6 +76,8 @@ def ptransform_by_matrix(a, matrix): def pmul(a, c): c = number(c) + if not a: + return (False, False, False) return (a[0] * c, a[1] * c, a[2] * c) @@ -85,6 +87,13 @@ def pdiv(a, c): def padd(a, b): + if not (a and b): + if a: + return (a[0], a[1], a[2]) + elif b: + return (b[0], b[1], b[2]) + else: + return (None, None, None) return (a[0] + b[0], a[1] + b[1], a[2] + b[2]) diff --git a/pycam/Geometry/Polygon.py b/pycam/Geometry/Polygon.py index c2457970..c5111cbb 100644 --- a/pycam/Geometry/Polygon.py +++ b/pycam/Geometry/Polygon.py @@ -231,8 +231,8 @@ def copy(self): def append(self, line): if not self.is_connectable(line): raise ValueError("This line does not fit to the polygon") - elif line.len < epsilon: - raise ValueError("A line with zero length may not be part of a polygon") + # elif line.len < epsilon: + # raise ValueError("A line with zero length may not be part of a polygon") else: if not self._points: self._points.append(line.p1)