Skip to content

Commit 5460dca

Browse files
Update jarvis_march.py
1 parent 7028fa7 commit 5460dca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

geometry/jarvis_march.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def jarvis_march(points: list[Point]) -> list[Point]:
188188
# Check if the last point is collinear with new point and second-to-last
189189
last = len(convex_hull) - 1
190190
if len(convex_hull) > 1 and _is_point_on_segment(
191-
points[current_idx], convex_hull[last - 1], convex_hull[last]
191+
convex_hull[last], convex_hull[last - 1], points[current_idx]
192192
):
193193
# Remove the last point from the hull
194194
convex_hull[last] = Point(points[current_idx].x, points[current_idx].y)
@@ -200,7 +200,7 @@ def jarvis_march(points: list[Point]) -> list[Point]:
200200
return []
201201

202202
last = len(convex_hull) - 1
203-
if _is_point_on_segment(convex_hull[0], convex_hull[last - 1], convex_hull[last]):
203+
if _is_point_on_segment(convex_hull[last], convex_hull[last - 1], convex_hull[0]):
204204
convex_hull.pop()
205205
if len(convex_hull) == 2:
206206
return []

0 commit comments

Comments
 (0)