Shape

Trait Shape 

Source
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§

Source

fn centroid(&self) -> Vec2<T>

Centroid of the shape.

Source

fn contains(&self, p: Vec2<T>) -> bool

If the point is contained within the shape.

Source

fn bounds(&self) -> Rect<T>

Rectangular bounds of the shape.

Source

fn project_onto_axis(&self, axis: Vec2<T>) -> Projection<T>

Project the shape onto the axis.

Source

fn project_point(&self, p: Vec2<T>) -> Vec2<T>

Project a point onto the outside surface of the shape.

Source

fn rayhit(&self, ray: &Ray<T>) -> bool

Check if a ray intersects this shape.

Source

fn raycast(&self, ray: &Ray<T>) -> Option<RayHit<T>>

Raycast against the shape.

Source

fn overlaps_rect(&self, rect: &Rect<T>) -> bool

If this shape overlaps the rectangle.

Source

fn overlaps_circ(&self, circ: &Circle<T>) -> bool

If this shape overlaps the circle.

Source

fn overlaps_poly<P: Polygonal<T>>(&self, poly: &P) -> bool

If this shape overlaps the polygon.

Source

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.

Source

fn extract_from_poly<P: Polygonal<T>>(&self, poly: &P) -> Option<Vec2<T>>

If this shape and the polygon overlap, return a push-out vector that can be used to extract them from each other.

Source

fn is_convex(&self) -> bool

If this shape is convex.

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: Float> Shape<T> for DynShape<T>

Source§

impl<T: Float> Shape<T> for Circle<T>

Source§

impl<T: Float> Shape<T> for Rect<T>

Source§

impl<T: Float, S: AsRef<[Vec2<T>]>> Shape<T> for S