HMath.Geometry.Polygon¶
Module index · Numerical conventions
Description
Planar hulls, polygon measurements and Boolean arrangements. Hulls return unique counterclockwise extreme vertices, omitting collinear interior points; 012-point hulls are valid. Boolean inputs are simple polygons with at most 128 vertices each. They use exact Rational edge splitting and local side classification, and return oriented rings: counterclockwise exterior rings, clockwise holes. Rings may share isolated boundary vertices. Coordinates are rounded to Double only at the output. This is a bounded reference arrangement, not a sweep-line implementation.
On this page¶
| API | Purpose |
|---|---|
| HullAlgorithm | Four distinct planar convex-hull construction algorithms. |
| GrahamScan | Declaration and type contract below. |
| MonotoneChain | Declaration and type contract below. |
| Quickhull | Declaration and type contract below. |
| GiftWrapping | Declaration and type contract below. |
| convexHull | Convex hull with at most 4096 input points. |
| polygonArea | Unsigned simple polygon area. |
| polygonCentroid | Area-weighted centroid; works for nonconvex simple polygons. |
| shoelace | Signed shoelace area; clockwise polygons have negative area. |
| BooleanOperation | Boolean set operation on closed polygon regions; ring boundaries have zero area. |
| Union | Declaration and type contract below. |
| Intersection | Declaration and type contract below. |
| Difference | Declaration and type contract below. |
| polygonBoolean | Exact edge-arrangement Boolean. |
| clipPolygon | Sutherland-Hodgman clipping against a convex CCW/clockwise clip polygon. |
| minimumBoundingCircle | Deterministic incremental minimum enclosing circle, O(n^3), at most 256 points. |
| minimumBoundingRectangle | Minimum-area oriented enclosing rectangle. |
| minkowskiSum | Convex Minkowski sum, via pairwise sums followed by a hull. |
Documentation
HullAlgorithm
data HullAlgorithm Source #
Four distinct planar convex-hull construction algorithms.
Constructors
| GrahamScan | |
| MonotoneChain | |
| Quickhull | |
| GiftWrapping |
Instances
| Show HullAlgorithm Source # | |
Defined in HMath.Geometry.Polygon Methods showsPrec :: Int -> HullAlgorithm -> ShowS # show :: HullAlgorithm -> String # showList :: [HullAlgorithm] -> ShowS # | |
| Eq HullAlgorithm Source # | |
Defined in HMath.Geometry.Polygon Methods (==) :: HullAlgorithm -> HullAlgorithm -> Bool # (/=) :: HullAlgorithm -> HullAlgorithm -> Bool # | |
convexHull
convexHull :: HullAlgorithm -> [Point2] -> Either MathError [Point2] Source #
Convex hull with at most 4096 input points. Exact orientation breaks degeneracies.
polygonCentroid
polygonCentroid :: Polygon -> Either MathError Point2 Source #
Area-weighted centroid; works for nonconvex simple polygons.
shoelace
shoelace :: Polygon -> Either MathError Double Source #
Signed shoelace area; clockwise polygons have negative area.
BooleanOperation
data BooleanOperation Source #
Boolean set operation on closed polygon regions; ring boundaries have zero area.
Constructors
| Union | |
| Intersection | |
| Difference |
Instances
| Show BooleanOperation Source # | |
Defined in HMath.Geometry.Polygon Methods showsPrec :: Int -> BooleanOperation -> ShowS # show :: BooleanOperation -> String # showList :: [BooleanOperation] -> ShowS # | |
| Eq BooleanOperation Source # | |
Defined in HMath.Geometry.Polygon Methods (==) :: BooleanOperation -> BooleanOperation -> Bool # (/=) :: BooleanOperation -> BooleanOperation -> Bool # | |
polygonBoolean
polygonBoolean :: BooleanOperation -> Polygon -> Polygon -> Either MathError [Polygon] Source #
Exact edge-arrangement Boolean. Empty output is allowed, including an intersection that consists only of points/segments (zero-area components).
clipPolygon
clipPolygon :: Polygon -> Polygon -> Either MathError [Point2] Source #
Sutherland-Hodgman clipping against a convex CCW/clockwise clip polygon. Output may be empty; nonconvex clippers fail instead of silently corrupting output.
minimumBoundingCircle
minimumBoundingCircle :: [Point2] -> Either MathError Circle Source #
Deterministic incremental minimum enclosing circle, O(n^3), at most 256 points. Each violated boundary introduces a 1-, 2-, or 3-point support.
minimumBoundingRectangle
minimumBoundingRectangle :: [Point2] -> Either MathError [Point2] Source #
Minimum-area oriented enclosing rectangle. Testing every hull edge uses the rotating-calipers extremal-orientation theorem; the reference scans all vertices for each orientation (O(h^2)), at most 4096 points.