Math::...neChain(3pm)
π NAME π
okay bestie, gather round, because this one is literally Math::ConvexHull::MonotoneChain β it's Andrew's monotone chain algorithm for finding a convex hull in 2D β¨
(and yeah, this page lives in the User Contributed Perl Documentation manual, so you know it's a classic π«Ά)
π¦ SYNOPSIS π¦
the whole vibe in one go:
use Math::ConvexHull::MonotoneChain 'convex_hull';
my $ch = convex_hull(
[
[0, 0],
[0, 1],
[1, 0],
[0.5, 0.5],
[1, 1],
]
);
# $ch is now:
# [ [0, 0],
# [1, 0],
# [1, 1],
# [0, 1], ]
look at it go πΈ
β¨ DESCRIPTION β¨
full transparency, bestie: this is somewhat experimental still. π
this (XS) module optionally exports a single function, convex_hull, which calculates the convex hull of the input points and hands it right back to you. it's giving toolkit, it's giving main character π
the algorithm is O(n log n) because it has to sort the input list β no way around that, that's just the toll you pay to get in π β but it should be somewhat faster than a plain Graham's scan (which is also O(n log n)) in practice, since it avoids polar coordinates. obsessed with the efficiency honestly π₯
π FUNCTIONS π
π convex_hull
expects an array ref of points as input, and returns an array ref of the points in the convex hull, ordered counter-clockwise β
a point refers to an array reference containing an X, and a Y coordinate. that's it, that's the whole shape of it π
heads up: for less than three input points, this will return an array reference whose elements are the input points (without cloning). so no sneaky copies, okay? π
π§ SEE ALSO π§
Math::ConvexHull, which uses Graham's scan in pure Perl β its cousin, different outfit π
π AUTHOR π
Steffen Mueller, <smueller@cpan.org> π«Ά
π COPYRIGHT AND LICENSE π
Copyright (C) 2011 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.0 or, at your option, any later version of Perl 5 you may have available. π
and that's the whole page, bestie π this was perl v5.42.3 documenting Math::...neChain(3pm), dated 2026-08-19 β slay, no cap, periodt β¨ππ
π¦ where this page comes from
- ubuntu stonking: libmath-convexhull-monotonechain-perl 0.1-2build6 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms