Skip to main content

FixedPolygon

Struct FixedPolygon 

Source
pub struct FixedPolygon<const N: usize> { /* private fields */ }
Expand description

A polygon with a statically-allocated vertex array of capacity N.

Vertices are stored inline; no heap allocation is performed.

Implementations§

Source§

impl<const N: usize> FixedPolygon<N>

Source

pub fn new() -> Self

Creates an empty FixedPolygon.

Source

pub fn try_push(&mut self, p: Point2D) -> bool

Attempts to push a vertex. Returns false if the polygon is full.

Source

pub fn len(&self) -> usize

Returns the number of vertices.

Source

pub fn is_empty(&self) -> bool

Returns true if the polygon has no vertices.

Source

pub fn vertices(&self) -> &[Point2D]

Returns a slice of the current vertices.

Source

pub fn signed_area(&self) -> f64

Computes the signed shoelace area (positive for CCW).

Source

pub fn area(&self) -> f64

Computes the absolute area using the shoelace formula.

Source

pub fn perimeter(&self) -> f64

Computes the perimeter (sum of edge lengths).

Source

pub fn bbox(&self) -> Option<BBox2D>

Returns the axis-aligned bounding box, or None if the polygon is empty.

Source

pub fn centroid(&self) -> Option<Point2D>

Computes the centroid, or None if the polygon is empty.

Trait Implementations§

Source§

impl<const N: usize> Default for FixedPolygon<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for FixedPolygon<N>

§

impl<const N: usize> RefUnwindSafe for FixedPolygon<N>

§

impl<const N: usize> Send for FixedPolygon<N>

§

impl<const N: usize> Sync for FixedPolygon<N>

§

impl<const N: usize> Unpin for FixedPolygon<N>

§

impl<const N: usize> UnsafeUnpin for FixedPolygon<N>

§

impl<const N: usize> UnwindSafe for FixedPolygon<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.