TL;DR
Take a finite set of points in the plane or in space. Their convex hull is the smallest convex set that contains all of them. Stretch a rubber band around the outermost points and let it snap tight: the region it encloses is the hull. Points strictly inside the band do not change the hull at all.
Where you'll see it: collision checking in robotics, where a robot's shape is approximated by the hull of its vertices; the feasible region of a linear program when its corners are the candidate solutions; and in computational geometry, where the hull is often the first step in analysing a point cloud.
Intuition
Imagine pins pushed into a board, one per point, and a loop of string around all of them. Pull the string tight and it will bend only at the pins on the outside. The shape it traces is the convex hull. A pin in the middle of the cluster never touches the string, so it can be removed without changing the shape.
Why does the idea exist? Many questions about a set of points are easier for the hull than for the points themselves. Is a point inside the set? Where is the furthest point in a direction? Does a robot touch a wall? In each case you only need the hull, because a convex region is fully described by its boundary, and its boundary is made of straight segments between a few corner points.
The hull is also the answer to a question about combinations. Pick any two points and draw the segment between them. The hull of a set is what you get by repeatedly drawing segments between points already in the region, which is why it is convex: a convex set is one where every segment between two of its points stays inside it, and the hull has that property by construction.
The math
The Convex Set lesson defines a set as convex when every segment between two of its points stays inside. For a finite set of points in , a convex combination is a point of the form
Each is a weight, the weights are nonnegative, and they add to one. A convex combination is a weighted average of the points.
The convex hull of is the set of all convex combinations of points of :
Equivalently, it is the intersection of all convex sets that contain , which is the smallest such set.
The two descriptions agree. Every convex set containing must contain every convex combination of its points, since convexity is closed under forming averages of that kind. The set of convex combinations is itself convex and contains , so it is the smallest one.
Extreme points
Not every point of is needed. A point is an extreme point of the hull if it is not a convex combination of the other points. Only extreme points can be corners of the hull. Every interior point is a convex combination of the extreme points, so the hull is determined by its extreme points alone. In the plane the extreme points are the vertices of the hull polygon, and in three dimensions they are its corners.
Membership test
Checking whether a point is in the hull is a linear feasibility problem. Ask whether there exist weights with and . A Linear Programming solver answers this directly. In two dimensions there is a simpler test, once the hull is known: a point is inside a convex polygon when it lies on the same side of every edge.
Computing the hull
The standard algorithm for points in the plane is Andrew's monotone chain. It sorts the points by -coordinate, then builds the lower and upper chains of the hull with a stack. The turn test uses the Cross Product: for points , and , the value is positive when the path turns left and negative when it turns right.
flowchart TD
A[Sort points by x then y] --> B[Build lower chain with a stack]
B --> C[Build upper chain in reverse order]
C --> D{Next point makes a non-left turn?}
D -- yes --> E[Pop the stack top]
E --> D
D -- no --> F[Push the point]
F --> G[Join the two chains into the hull]
Sorting costs and the stack pass is linear, so the whole algorithm runs in . This is optimal for planar hulls, because sorting can be reduced to finding the hull.
Worked examples
Take four points: , , and .
- Find the hull's edges. The bottom edge joins and because all points lie on or above the line .
- The right edge joins and . This line is . Check the other points: gives and gives , so both are on the same side.
- The left edge joins and . This line is . The point gives and gives , so both are below it.
- Since satisfies every edge inequality, it is inside. The hull is the triangle , and does not affect it.
- The area of the triangle is half the absolute value of the cross product of and , which is .
Interpretation: the four points span a region of area 6. The point is a redundant point, and removing it changes nothing.
Show that is in the hull of , and by finding weights that sum to 1 and average to .
- The -coordinates give , so .
- The -coordinates give , so and .
- The weights sum to 1, so .
- All three are nonnegative. Check: and .
Interpretation: is a weighted average of the three corners, with most weight on and least on . Had any weight come out negative, the point would lie outside the hull.
Tradeoffs and failure modes
| Situation | Problem | Better choice |
|---|---|---|
| Points in the plane or 3D, many of them | Naive pairwise tests are slow | Monotone chain for the plane; a dedicated library such as Qhull for 3D |
| Very high dimension | The number of facets can explode | Avoid the exact hull; use a linear program or an approximation |
| Nearly collinear points | Floating-point error can flip a turn test and add or drop a vertex | Use exact arithmetic or a tolerance and state it |
| You only need membership, not the shape | Building the full hull is wasted work | Solve a linear feasibility problem for the one point |
| Data with outliers | The hull is dominated by a single far point | Use a robust summary, such as a percentile region |
A common pitfall is treating the hull as a model of the data. It is only the outer boundary. A cloud of points that is shaped like a ring has a filled-in hull, so the hull says nothing about the hole in the middle.
History
The notion of a convex set and the idea of a hull were developed in the late nineteenth and early twentieth centuries, when geometers studied convex bodies and their supporting planes. Carathéodory's theorem, which says that a point in the hull of a set in dimensions is a convex combination of at most of the points, dates to the early 1900s and is the reason the hull of a planar set is determined by only a few vertices.
Algorithms came later, with the rise of computing. Ronald Graham published a scan that sorts by angle around a chosen interior point in 1972. Jarvis's "gift wrapping" method, which walks around the hull one vertex at a time, appeared in the early 1970s. Andrew's monotone chain, a simpler sort-and-scan approach, followed in the late 1970s and remains the usual choice in code. The idea caught on in computational geometry and later in optimization, because linear programs and support-vector methods can be stated in terms of hulls.
Check yourself
QuestionRecall: what is the convex hull of a set of points?Show answer
It is the smallest convex set containing all the points. Equivalently, it is the set of all convex combinations of the points, meaning weighted averages with nonnegative weights that sum to one.
QuestionCompute the area of the hull of the three points , and .Show answer
The hull of three points that are not collinear is the triangle they form. Its area is half the absolute value of the cross product of and , which is .
QuestionWhy does an interior point never change the convex hull, and why is that useful?Show answer
An interior point is a convex combination of the other points, so it is already inside the hull they define. Removing it leaves the hull unchanged. This is why algorithms only need to track the extreme points, which often are far fewer than the whole set.
QuestionA robot arm's shape is approximated by the convex hull of its vertices, and a wall is a flat line. Explain how the hull helps decide whether the arm touches the wall.Show answer
A convex polygon lies entirely on one side of the wall if all its vertices do. So it is enough to check the vertices: if all lie strictly on one side, the hull does not touch the wall. If vertices lie on both sides, the hull crosses it and the arm touches. Only the vertices are needed, not every point of the arm.
Sources
- Convex hull (Wikipedia)
- Convex hull algorithms (Wikipedia)
- Boyd, S. and Vandenberghe, L., Convex Optimization, free online edition