Skip to content

Commit

Permalink
fix(polygon): Fix bug in self-intersect check for clockwise polygons
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Nov 14, 2024
1 parent dfcaffa commit da11268
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ladybug_geometry/geometry2d/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,14 +835,15 @@ def offset(self, distance, check_intersection=False):

# check for self intersection between the moving vectors if requested
if check_intersection:
poly_segs = new_poly.segments
poly_segs = new_poly.segments if not self.is_clockwise else \
Polygon2D(tuple(reversed(new_pts))).segments
_segs = [LineSegment2D(p, v) for p, v in zip(init_verts, move_vecs)]
_skip = (0, len(_segs) - 1)
_other_segs = [x for j, x in enumerate(poly_segs) if j not in _skip]
for _oth_s in _other_segs:
if _segs[0].intersect_line_ray(_oth_s) is not None: # intersection!
return None
for i, _s in enumerate(_segs[1: len(_segs)]):
for i, _s in enumerate(_segs[1:]):
_skip = (i, i + 1)
_other_segs = [x for j, x in enumerate(poly_segs) if j not in _skip]
for _oth_s in _other_segs:
Expand Down

0 comments on commit da11268

Please sign in to comment.