Skip to main content

Module polygon

Module polygon 

Source
Expand description

Polygon operations: area, centroid, convex hull, winding.

All functions operate on slices of (f64, f64) tuples for maximum compatibility. Use Point2::to_tuple() for interop.

§References

  • O’Rourke (1998), “Computational Geometry in C”, Ch.1 (polygon area)
  • Graham (1972), “An efficient algorithm for determining the convex hull”
  • de Berg et al. (2008), “Computational Geometry”, Ch.1

Functions§

area
Computes the unsigned area of a simple polygon.
area_with_holes
Computes the unsigned area of a polygon with holes.
centroid
Computes the centroid (center of mass) of a simple polygon.
centroid_with_holes
Computes the centroid of a polygon with holes.
contains_point
Checks if a point lies inside a simple polygon using the winding number method.
convex_hull
Computes the convex hull of a set of points using Graham scan.
ensure_ccw
Ensures a polygon has counter-clockwise winding order.
is_convex
Checks if a simple polygon is convex.
perimeter
Computes the perimeter of a polygon.
signed_area
Computes the signed area of a simple polygon using the Shoelace formula.