pub struct FixedRing<const N: usize> { /* private fields */ }Expand description
A fixed-capacity closed ring backed by an inline array.
The ring is implicitly closed: the edge from vertices[len-1] back to
vertices[0] is always present when the ring has 3+ vertices.
Implementations§
Source§impl<const N: usize> FixedRing<N>
impl<const N: usize> FixedRing<N>
Sourcepub fn push(&mut self, p: Point2D) -> Result<(), NoAllocError>
pub fn push(&mut self, p: Point2D) -> Result<(), NoAllocError>
Attempts to append a vertex. Returns Ok(()) on success or
Err(NoAllocError::CapacityExceeded) if the ring is full.
Sourcepub fn get(&self, index: usize) -> Option<&Point2D>
pub fn get(&self, index: usize) -> Option<&Point2D>
Returns the vertex at the given index, or None if out of bounds.
Sourcepub fn signed_area(&self) -> f64
pub fn signed_area(&self) -> f64
Computes the signed area using the shoelace formula.
Positive for counter-clockwise winding, negative for clockwise.
Returns 0.0 if the ring has fewer than 3 vertices.
Sourcepub fn is_counter_clockwise(&self) -> bool
pub fn is_counter_clockwise(&self) -> bool
Returns true if the ring’s vertices are ordered counter-clockwise.
A ring with fewer than 3 vertices is considered neither CW nor CCW
and returns false.
Sourcepub fn is_clockwise(&self) -> bool
pub fn is_clockwise(&self) -> bool
Returns true if the ring’s vertices are ordered clockwise.
Sourcepub fn contains_point(&self, p: Point2D) -> bool
pub fn contains_point(&self, p: Point2D) -> bool
Tests whether a point lies inside or on the boundary of the ring using the ray-casting algorithm.
A horizontal ray from the point toward +X is tested against each edge of the ring. An odd number of crossings means the point is inside.
Returns false for rings with fewer than 3 vertices.