MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _find_next_hull_point

Function _find_next_hull_point

geometry/jarvis_march.py:83–97  ·  view source on GitHub ↗

Find the next point on the convex hull.

(points: list[Point], current_idx: int)

Source from the content-addressed store, hash-verified

81
82
83def _find_next_hull_point(points: list[Point], current_idx: int) -> int:
84 """Find the next point on the convex hull."""
85 next_idx = (current_idx + 1) % len(points)
86 # Ensure next_idx is not the same as current_idx
87 while next_idx == current_idx:
88 next_idx = (next_idx + 1) % len(points)
89
90 for i in range(len(points)):
91 if i == current_idx:
92 continue
93 cross = _cross_product(points[current_idx], points[i], points[next_idx])
94 if cross > 0:
95 next_idx = i
96
97 return next_idx
98
99
100def _is_valid_polygon(hull: list[Point]) -> bool:

Callers 1

jarvis_marchFunction · 0.85

Calls 1

_cross_productFunction · 0.85

Tested by

no test coverage detected