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.
Trait Implementations§
impl StructuralPartialEq for Polygon
Auto Trait Implementations§
impl Freeze for Polygon
impl RefUnwindSafe for Polygon
impl Send for Polygon
impl Sync for Polygon
impl Unpin for Polygon
impl UnsafeUnpin for Polygon
impl UnwindSafe for Polygon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more