Monotone Chain Hulls: Remove the Turn That Bends Inward
2026-11-19

Monotone Chain Hulls: Remove the Turn That Bends Inward

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.

Sort coordinates before building either chain

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.

A0,0 B1,1 C2,0 crossnegative2 popB leavesAC
Illustrative lower-chain rule retains strictly counterclockwise turns. Zhilianhai editorial desk, original AI-assisted concept diagram.

A signed cross product detects the turn

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.

An independent trace removes the middle candidate

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.

A0,0 C2,0 D2,2 finaltriangle B1,1 onDA diagonal omitted
Minimal-vertex hull, not an assertion that every boundary sample appears in returned vector. Zhilianhai editorial desk, original AI-assisted concept diagram.

Collinear handling changes the output contract

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.

The stack work is linear after sorting

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.

Read the returned order with its convention

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.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我