pub trait Shape<T> {
Show 13 methods
// Required methods
fn centroid(&self) -> Vec2<T>;
fn contains(&self, p: Vec2<T>) -> bool;
fn bounds(&self) -> Rect<T>;
fn project_onto_axis(&self, axis: Vec2<T>) -> Projection<T>;
fn project_point(&self, p: Vec2<T>) -> Vec2<T>;
fn rayhit(&self, ray: &Ray<T>) -> bool;
fn raycast(&self, ray: &Ray<T>) -> Option<RayHit<T>>;
fn overlaps_rect(&self, rect: &Rect<T>) -> bool;
fn overlaps_circ(&self, circ: &Circle<T>) -> bool;
fn overlaps_poly<P: Polygonal<T>>(&self, poly: &P) -> bool;
fn extract_from_circ(&self, circ: &Circle<T>) -> Option<Vec2<T>>;
fn extract_from_poly<P: Polygonal<T>>(&self, poly: &P) -> Option<Vec2<T>>;
fn is_convex(&self) -> bool;
}Expand description
A type that represents a convex 2D shape.
Required Methods§
Sourcefn project_onto_axis(&self, axis: Vec2<T>) -> Projection<T>
fn project_onto_axis(&self, axis: Vec2<T>) -> Projection<T>
Project the shape onto the axis.
Sourcefn project_point(&self, p: Vec2<T>) -> Vec2<T>
fn project_point(&self, p: Vec2<T>) -> Vec2<T>
Project a point onto the outside surface of the shape.
Sourcefn overlaps_rect(&self, rect: &Rect<T>) -> bool
fn overlaps_rect(&self, rect: &Rect<T>) -> bool
If this shape overlaps the rectangle.
Sourcefn overlaps_circ(&self, circ: &Circle<T>) -> bool
fn overlaps_circ(&self, circ: &Circle<T>) -> bool
If this shape overlaps the circle.
Sourcefn overlaps_poly<P: Polygonal<T>>(&self, poly: &P) -> bool
fn overlaps_poly<P: Polygonal<T>>(&self, poly: &P) -> bool
If this shape overlaps the polygon.
Sourcefn extract_from_circ(&self, circ: &Circle<T>) -> Option<Vec2<T>>
fn extract_from_circ(&self, circ: &Circle<T>) -> Option<Vec2<T>>
If this shape and the circle overlap, return a push-out vector that can be used to extract them from each other.
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.