Trait Shape2D

Source
pub trait Shape2D {
    type Value;
    type VertexIterator<'a>: Iterator<Item = Point<Self::Value>>
       where Self: 'a;
    type LineIterator<'a>: Iterator<Item = Line<Self::Value>>
       where Self: 'a;

    // Required methods
    fn is_valid(&self) -> bool;
    fn boundary(&self) -> Rectangle<Self::Value>;
    fn vertices<'a>(&'a self, sample: usize) -> Self::VertexIterator<'a>;
    fn edges<'a>(&'a self, sample: usize) -> Self::LineIterator<'a>;

    // 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.

Source

type VertexIterator<'a>: Iterator<Item = Point<Self::Value>> where Self: 'a

The value type of the shape.

Source

type LineIterator<'a>: Iterator<Item = Line<Self::Value>> where Self: 'a

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<'a>(&'a self, sample: usize) -> Self::VertexIterator<'a>

Returns the owned vertices of the shape.

Notice that sample only works for non-linear shapes.

Source

fn edges<'a>(&'a self, sample: usize) -> Self::LineIterator<'a>

Returns the owned edges of the shape.

Provided Methods§

Source

fn normalize(&mut self) -> bool

Returns true if the shape successfully normalized.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

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

Source§

type Value = T

Source§

type VertexIterator<'a> = PointsIterator<'a, T> where T: 'a

Source§

type LineIterator<'a> = IntoIter<Line<T>> where T: 'a

Source§

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

Source§

type Value = T

Source§

type VertexIterator<'a> = PointsIterator<'a, T> where T: 'a

Source§

type LineIterator<'a> = IntoIter<Line<T>> where T: 'a

Source§

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

Source§

type Value = T

Source§

type VertexIterator<'a> = IntoIter<Point<T>> where T: 'a

Source§

type LineIterator<'a> = IntoIter<Line<T>> where T: 'a

Source§

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

Source§

type Value = T

Source§

type VertexIterator<'a> = IntoIter<Point<T>> where T: 'a

Source§

type LineIterator<'a> = IntoIter<Line<T>> where T: 'a

Source§

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

Source§

type Value = T

Source§

type VertexIterator<'a> = IntoIter<Point<T>> where T: 'a

Source§

type LineIterator<'a> = IntoIter<Line<T>> where T: 'a