Skip to content

Commit ba711a2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent abed1d0 commit ba711a2

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

geometry/jarvis_march.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def _cross_product(origin: Point, point_a: Point, point_b: Point) -> float:
5050
= 0: Collinear
5151
< 0: Clockwise turn (right turn)
5252
"""
53-
return (point_a.x - origin.x) * (point_b.y - origin.y) - (
54-
point_a.y - origin.y
55-
) * (point_b.x - origin.x)
53+
return (point_a.x - origin.x) * (point_b.y - origin.y) - (point_a.y - origin.y) * (
54+
point_b.x - origin.x
55+
)
5656

5757

5858
def _is_point_on_segment(p1: Point, p2: Point, point: Point) -> bool:
@@ -111,9 +111,7 @@ def _is_valid_polygon(hull: list[Point]) -> bool:
111111
def _add_point_to_hull(hull: list[Point], point: Point) -> None:
112112
"""Add a point to hull, removing collinear intermediate points."""
113113
last = len(hull) - 1
114-
if len(hull) > 1 and _is_point_on_segment(
115-
hull[last - 1], hull[last], point
116-
):
114+
if len(hull) > 1 and _is_point_on_segment(hull[last - 1], hull[last], point):
117115
hull[last] = Point(point.x, point.y)
118116
else:
119117
hull.append(Point(point.x, point.y))
@@ -170,9 +168,7 @@ def jarvis_march(points: list[Point]) -> list[Point]:
170168

171169
# Check if last point is collinear with first and second-to-last
172170
last = len(convex_hull) - 1
173-
if _is_point_on_segment(
174-
convex_hull[last - 1], convex_hull[last], convex_hull[0]
175-
):
171+
if _is_point_on_segment(convex_hull[last - 1], convex_hull[last], convex_hull[0]):
176172
convex_hull.pop()
177173
if len(convex_hull) == 2:
178174
return []

0 commit comments

Comments
 (0)