Finding the Convex Hull of a set of points is an interesting problem in computational geometry. It is useful as a building block for a diverse set of applications, including thing such as:
Collision detection in video games, providing a useful replacement for bounding boxes.
Visual pattern matching/object detection
Mapping
Path determination
Just as an example, if one of the Mars rovers has to chart a path around a boulder, the convex hull can be used to provide the shortest path past the obstacle, given a map that shows the points where the boulder abuts the ground.
This article will go over the definition of the 2D convex hull, describe Graham’s efficient algorithm for finding the convex hull of a set of points, and present a sample C++ program that can be used to experiment with the algorithm.
The Convex Hull
There are many ways to draw a boundary around a set of points in a two-dimensional plane. One of the easiest to implement is a bounding-box, which is a rectangle that spans the set from its minimum and maximum points in the X and Y planes.
Creating a bounding-box is easy, but it doesn’t form as tight a wrapper as we might like around a set of points. Consider the bounding box around the three points shown in Figure 1.

Figure 1 - A standard bounding box around three points
We can certainly wrap those points much more tightly using easy-to-compute straight lines, and Figure 2 shows an example that is significantly more compact:

Figure 2 - A convex hull around the three points from Figure 1
As it happens, Figure 2 is a convex hull.
Continue reading this post…