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

Function _is_valid_polygon

geometry/jarvis_march.py:100–108  ·  view source on GitHub ↗

Check if hull forms a valid polygon (has at least one non-collinear turn).

(hull: list[Point])

Source from the content-addressed store, hash-verified

98
99
100def _is_valid_polygon(hull: list[Point]) -> bool:
101 """Check if hull forms a valid polygon (has at least one non-collinear turn)."""
102 for i in range(len(hull)):
103 p1 = hull[i]
104 p2 = hull[(i + 1) % len(hull)]
105 p3 = hull[(i + 2) % len(hull)]
106 if abs(_cross_product(p1, p2, p3)) > 1e-9:
107 return True
108 return False
109
110
111def _add_point_to_hull(hull: list[Point], point: Point) -> None:

Callers 1

jarvis_marchFunction · 0.85

Calls 1

_cross_productFunction · 0.85

Tested by

no test coverage detected