Find the next point on the convex hull.
(points: list[Point], current_idx: int)
| 81 | |
| 82 | |
| 83 | def _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 | |
| 100 | def _is_valid_polygon(hull: list[Point]) -> bool: |
no test coverage detected