Skip to content

Commit

Permalink
fix point_in_polygon method when the asum was a multiple of 2*phi (#4495
Browse files Browse the repository at this point in the history
)

Co-authored-by: maxcapodi78 <Shark78>
Co-authored-by: adimaria <[email protected]>
  • Loading branch information
maxcapodi78 and Alberto-DM authored Apr 15, 2024
1 parent b45cf01 commit 0f891b9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pyaedt/modeler/geometry_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,8 @@ def point_in_polygon(point, polygon, tolerance=1e-8):
The method implements the radial algorithm (https://es.wikipedia.org/wiki/Algoritmo_radial)
This version supports also self-intersecting polygons.
point : List
List of ``[x, y]`` coordinates.
polygon : List
Expand Down Expand Up @@ -1591,9 +1593,10 @@ def point_in_polygon(point, polygon, tolerance=1e-8):
if abs(abs(a) - math.pi) < tol:
return 0
asum += a
r = asum % (2*math.pi)
if abs(asum) < tol:
return -1
elif abs(abs(asum) - 2*math.pi) < tol:
elif r < tol or (2*math.pi - r) < tol:
return 1
else: # pragma: no cover
raise Exception("Unexpected error!")
Expand Down

0 comments on commit 0f891b9

Please sign in to comment.