pub struct Polygon { /* private fields */ }Expand description
Simple polygon obstacle: closed ordered vertex ring, not necessarily convex.
Does not auto-validate. Scene validation requires at least three distinct vertices, non-zero area, vertices inside world bounds, no self-intersections, and pairwise disjointness with other obstacles.
Implementations§
Source§impl Polygon
impl Polygon
Sourcepub fn new(vertices: Vec<Point2>) -> Polygon
pub fn new(vertices: Vec<Point2>) -> Polygon
Builds an obstacle from a vertex ring. Does not check geometry invariants.
Sourcepub fn vertices(&self) -> &[Point2]
pub fn vertices(&self) -> &[Point2]
Obstacle ring vertices in declaration order (not rewound by constructors).
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Shoelace signed area (positive for counter-clockwise rings in this coordinate system).
Absolute value near zero is treated as degenerate during validation.
Sourcepub fn contains_point_strict(&self, point: Point2) -> bool
pub fn contains_point_strict(&self, point: Point2) -> bool
Ray-cast interior test: true only for strict interior points.
Points on any edge of the boundary ring return false (boundary is free
space unless the edge is sealed against the world boundary).
Sourcepub fn validate(
&self,
world_bounds: WorldBounds,
) -> Result<(), PolygonValidationError>
pub fn validate( &self, world_bounds: WorldBounds, ) -> Result<(), PolygonValidationError>
Validates this obstacle as if it were obstacle index 0 in world_bounds.
§Errors
Returns a PolygonValidationError describing the violated polygon
geometry invariant.