Skip to main content

Shape

Trait Shape 

Source
pub trait Shape<const D: usize>: Send + Sync {
    // Required methods
    fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>;
    fn bounding_sphere(&self) -> (Point<D>, f64);
    fn as_any(&self) -> &dyn Any;
    fn clone_box(&self) -> Box<dyn Shape<D>>;
}
Expand description

Trait for D-dimensional convex shapes compatible with GJK collision detection.

The support function is the only requirement for GJK — given a direction, return the point on the shape’s boundary furthest in that direction. This generalizes naturally to any dimension.

Required Methods§

Source

fn support(&self, direction: &SVector<f64, D>) -> SVector<f64, D>

Support function: furthest point on the boundary in the given direction.

Source

fn bounding_sphere(&self) -> (Point<D>, f64)

Bounding sphere: (center, radius).

Source

fn as_any(&self) -> &dyn Any

Downcast to concrete type for specialized collision dispatch.

Source

fn clone_box(&self) -> Box<dyn Shape<D>>

Clone this shape into a new box.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const D: usize> Shape<D> for Capsule<D>

Source§

impl<const D: usize> Shape<D> for CompoundShape<D>

Source§

impl<const D: usize> Shape<D> for ConvexHull<D>

Source§

impl<const D: usize> Shape<D> for HalfSpace<D>

Source§

impl<const D: usize> Shape<D> for HyperBox<D>

Source§

impl<const D: usize> Shape<D> for Sphere<D>