Connection
Base URL, credentials and a reachable server.
Use convex_hull.py to examine which collinear points disappear from the boundary of a convex hull.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
def convex_hull(points):
if type(points) is not list or len(points) > 1000:
raise ValueError("hull.input")
if any(type(p) not in (tuple, list) or len(p) != 2 or
any(type(v) is not int for v in p) for p in points):
raise ValueError("hull.point")
ordered = sorted(set(map(tuple, points)))
if len(ordered) <= 1:
return ordered
def turn(a,b,c):
return (b[0]-a[0])*(c[1]-a[1])-(b[1]-a[1])*(c[0]-a[0])
def chain(sequence):
out = []
for p in sequence:
while len(out) >= 2 and turn(out[-2],out[-1],p) <= 0:
out.pop()
out.append(p)
return out
return chain(ordered)[:-1]+chain(reversed(ordered))[:-1]