A lattice point
is a point with integer
coordinates. A lattice polygon is a polygon with all vertices lattice points.
A polygon is convex
if any line segment between two points of the polygon is inside (or on the boundary of) the polygon. Equivalently, the interior angle at each polygon vertex is less than 180 degrees.
For a set S, of lattice points, the convex hull
is the smallest convex (lattice) polygon which contains all points of the set. (The vertices of the convex hull must be members of the set of lattice points). If all the points are on a single straight line, the convex hull will be a line segment (a degenerate
polygon – see rightmost diagram below). In the diagrams below, the points of the set are indicated by solid dots, the vertices of the convex hull by X’s and the convex hull is drawn connecting the vertices. Note that not all points on the convex hull polygon are vertices.
The vertices of a lattice polygon are in standard order if:
a) The first vertex is the one with the largest y value. If two vertices have the same y value, the one with the smaller x value is the first.
b) Vertices are given in clockwise order around the polygon.
Write a program that reads a set of lattice points and outputs the vertices of the convex hull of the points in standard order.