Monotone Chain construction builds a planar convex hull by sorting points and removing turns that would bend a boundary inward. The method uses two related stacks for the lower and upper chains. A point removed from one chain is not being deleted from the original data set; it is being rejected as a necessary vertex of that particular boundary.
Use lexicographic order: increasing horizontal coordinate, then increasing vertical coordinate for ties. This gives a consistent traversal from the leftmost point toward the rightmost point. Duplicate coordinates should follow an explicit input policy, such as keeping one occurrence for geometric construction while storing external identities separately.
For a minimal-vertex hull, the lower chain can be built by retaining strictly counterclockwise turns during the left-to-right scan. Scanning the same points in reverse with the same turn rule produces the upper chain. Joining them omits duplicate endpoints. Other equivalent presentations use separate clockwise and counterclockwise tests while scanning forward, so their output orientation may differ.

For consecutive candidate points A, B and a new point C, take the two vectors B minus A and C minus A. Their signed two-dimensional cross product is positive for a counterclockwise turn, negative for a clockwise turn and zero for collinearity. The sign, rather than the magnitude alone, determines which turn is present.
In the stated lower-chain convention, pop B while there are at least two existing stack points and the cross product is nonpositive. Repeat the test against the newly exposed pair, then push C. One incoming point can remove several previous candidates. Stopping after only one pop can leave an earlier inward bend on the resulting chain.
Choose A=(0,0), B=(1,1), C=(2,0) and D=(2,2). They are already in lexicographic order. Starting with A and B, the arrival of C gives cross product negative two. The lower chain removes B and becomes A,C. Adding D gives a positive turn, leaving A,C,D.
The reverse scan builds the complementary chain. In the final minimal hull, B lies on the diagonal from D to A and is omitted under the policy that removes intermediate collinear boundary points. The hull is the triangle A,C,D. B remains enclosed on its boundary; its absence from the vertex list does not mean it lies outside the hull.

Keeping only extreme endpoints on a straight edge and keeping every input point along that edge are both useful output conventions. They are not interchangeable. Changing a nonpositive pop test to a strictly negative test can retain collinear points, but the all-collinear case and endpoint concatenation still need special handling to avoid repetitions.
A set with one unique point has a point hull, and a collinear set with at least two unique points has a segment hull under the minimal-vertex convention. An empty set also needs a documented result. A routine written for nonempty input may access an endpoint before any main loop begins. These degenerate inputs should not be interpreted as ordinary polygons with an interior area.
Each point is pushed once and can be popped at most once per chain. A scan containing a while loop therefore does not imply quadratic total stack work. Summing pushes and pops over the scan gives a linear bound, while sorting supplies the usual overall logarithmic factor for arbitrary unsorted planar points.
This accounting concerns the operation count for the specified representation. Integer coordinate subtraction and cross-product multiplication must still fit the chosen arithmetic type. For floating inputs, nearly collinear points can be numerically difficult to classify. A tolerance changes the geometric classification policy and should be selected and described deliberately, rather than silently treated as exact arithmetic.
Coordinates supplied in a different axis convention can also reverse the apparent turn on a displayed screen. The arithmetic orientation rule belongs to the chosen coordinate system. A plot with downward-increasing vertical coordinates should not silently redefine the sign used by the mathematical construction.
KACTL's cited routine documents counterclockwise hull vertices and excludes points between other hull vertices on a straight edge. The CP Algorithms presentation also discusses an inclusive-collinear option and its degenerate case. Neither description makes a convex hull preserve concave recesses, attached point attributes or a manufactured part's physical dimensions.
A closed drawing may repeat its starting vertex, while a returned vertex vector may leave closure implicit. The site's planar geometry principles and algorithm features connect representation and construction. Primary sources: KACTL's original two-pass orientation stack and CP Algorithms' monotone-chain derivation and collinearity discussion. Both figures are original AI-assisted point and stack diagrams.