Expand description
Polygon operations module
This module provides functionality for working with polygons, including:
- Point in polygon testing
- Area and centroid calculations
- Polygon operations (simplification, transformation)
§Examples
use scirs2_core::ndarray::array;
use scirs2_spatial::polygon::point_in_polygon;
// Create a square polygon
let polygon = array![
[0.0, 0.0],
[1.0, 0.0],
[1.0, 1.0],
[0.0, 1.0],
];
// Test if a point is inside
let inside = point_in_polygon(&[0.5, 0.5], &polygon.view());
assert!(inside);
// Test if a point is outside
let outside = point_in_polygon(&[1.5, 0.5], &polygon.view());
assert!(!outside);Functions§
- convex_
hull_ graham - Compute the convex hull of a polygon using the Graham scan algorithm.
- douglas_
peucker_ simplify - Simplify a polygon using the Douglas-Peucker algorithm.
- is_
simple_ polygon - Check if a polygon is simple (non-self-intersecting).
- point_
in_ polygon - Tests if a point is inside a polygon using the ray casting algorithm.
- point_
on_ boundary - Tests if a point is on the boundary of a polygon.
- polygon_
area - Calculate the area of a simple polygon.
- polygon_
centroid - Calculate the centroid of a simple polygon.
- polygon_
contains_ polygon - Tests if polygon A contains polygon B (every point of B is inside or on the boundary of A).
- visvalingam_
whyatt_ simplify - Simplify a polygon using the Visvalingam-Whyatt algorithm.