Welcome to the Convex Hull page! Here, you’ll find a description of the project as well as a list of sample programs written in various languages.
Suppose you have a set of points in the plane. The convex hull of this set is the smallest convex polygon that contains all the points.
A good way to visualize the problem is this: Imagine each point is a nail sticking out of the plane, and you stretch a rubber band around them and let it go. The band will contract and assume a shape that encloses the nails. This shape is the convex hull.
Note that all vertices of the convex hull are points in the original set. So the convex hull is really a subset of points from the original set, and there may be points that lie inside the polygon but are not vertices of the convex hull.
Write a program that receives two command line arguments: strings in the form
x1, x2, x3 ... and
y1, y2, y3 ... respectively, where
(xi, yi) are the coordinates of the i-th point of the set.
Your program should be able to parse these lists into some internal representation in your choice language (ideally an array). From there, the program should compute the convex hull of the set of points, and output a list in the form
(x1, y1) (x2, y2) ...
(xj, yj) are the coordinates of the j-th vertex of the convex hull.
There are many algorithms to solve this problem. You may implement any of them. Check this [great document by Jeff Erickson] for more details about the problem and the different algorithms to solve it.
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Convex Hull. To keep things simple, we split up testing into two subsets: valid and invalid. Valid tests refer to tests that occur under correct input conditions. Invalid tests refer to tests that occur on bad input (e.g., letters instead of numbers).
|Description||Input X||Input Y||Output|
|Cluster in center||
Note: different algorithms could produce the output starting from a different point, and/or in the opposite direction.
|Description||Input X||Input Y|
|Too few values||
All invalid tests should spit out a usage statement in the following form:
Usage: please provide at least 3 x and y coordinates as separate lists (e.g. "100, 440, 210")