Trait shape_core::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.

Object Safety§

This trait is not object safe.

Implementors§

source§

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

§

type Value = T

§

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

§

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

source§

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

§

type Value = T

§

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

§

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

source§

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

§

type Value = T

§

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

§

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

source§

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

§

type Value = T

§

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

§

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

source§

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

§

type Value = T

§

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

§

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