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.
returns: Triangle
The value type of the shape.
Returns true if the shape is valid and in normal form.
Returns the boundary of the shape.
Returns the owned vertices of the shape.
Notice that sample only works for non-linear shapes.
Returns the owned edges of the shape.
Returns true if the shape successfully normalized.