Trait shape_core::Shape2D

source ·
pub trait Shape2D {
    type Value;

    // Required methods
    fn is_valid(&self) -> bool;
    fn boundary(&self) -> Rectangle<Self::Value>;
    fn vertices(
        &self,
        sample: usize
    ) -> impl Iterator<Item = Point<Self::Value>> + '_;
    fn edges(
        &self,
        sample: usize
    ) -> impl Iterator<Item = Line<Self::Value>> + '_;

    // Provided method
    fn normalize(&mut self) -> bool { ... }
}
Expand description

The trait for 2D shapes.

Arguments

  • a:
  • b:
  • c:

returns: Triangle

Examples

Required Associated Types§

source

type Value

The value type of the shape.

Required Methods§

source

fn is_valid(&self) -> bool

Returns true if the shape is valid and in normal form.

source

fn boundary(&self) -> Rectangle<Self::Value>

Returns the boundary of the shape.

source

fn vertices( &self, sample: usize ) -> impl Iterator<Item = Point<Self::Value>> + '_

Returns the owned vertices of the shape.

Notice that sample only works for non-linear shapes.

source

fn edges(&self, sample: usize) -> impl Iterator<Item = Line<Self::Value>> + '_

Returns the owned edges of the shape.

Provided Methods§

source

fn normalize(&mut self) -> bool

Returns true if the shape successfully normalized.

Implementors§

source§

impl<T> Shape2D for PointSet<T>where T: NumOps + PartialOrd + Clone,

§

type Value = T

source§

impl<T> Shape2D for Polygon<T>where T: NumOps + PartialOrd + Clone,

§

type Value = T

source§

impl<T> Shape2D for Rectangle<T>where T: Signed + Clone + PartialOrd,

§

type Value = T

source§

impl<T> Shape2D for Square<T>where T: Signed + Clone + PartialOrd,

§

type Value = T

source§

impl<T> Shape2D for Triangle<T>where T: Clone + PartialOrd + Num,

§

type Value = T