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

Function _add_point_to_hull

geometry/jarvis_march.py:111–117  ·  view source on GitHub ↗

Add a point to hull, removing collinear intermediate points.

(hull: list[Point], point: Point)

Source from the content-addressed store, hash-verified

109
110
111def _add_point_to_hull(hull: list[Point], point: Point) -> None:
112 """Add a point to hull, removing collinear intermediate points."""
113 last = len(hull) - 1
114 if len(hull) > 1 and _is_point_on_segment(hull[last - 1], hull[last], point):
115 hull[last] = Point(point.x, point.y)
116 else:
117 hull.append(Point(point.x, point.y))
118
119
120def jarvis_march(points: list[Point]) -> list[Point]:

Callers 1

jarvis_marchFunction · 0.85

Calls 3

_is_point_on_segmentFunction · 0.85
PointClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected