Struct GJK

Source
pub struct GJK<SP, E, S> { /* private fields */ }
Expand description

Gilbert-Johnson-Keerthi narrow phase collision detection algorithm.

§Type parameters:

Implementations§

Source§

impl<SP, E, S> GJK<SP, E, S>
where SP: SimplexProcessor, SP::Point: EuclideanSpace<Scalar = S>, S: BaseFloat, E: EPA<Point = SP::Point>,

Source

pub fn new() -> Self

Create a new GJK algorithm implementation

Source

pub fn new_with_settings( distance_tolerance: S, continuous_tolerance: S, epa_tolerance: S, max_iterations: u32, ) -> Self

Create a new GJK algorithm implementation with the given tolerance settings

Source

pub fn intersect<P, PL, PR, TL, TR>( &self, left: &PL, left_transform: &TL, right: &PR, right_transform: &TR, ) -> Option<SmallVec<[SupportPoint<P>; 5]>>
where P: EuclideanSpace<Scalar = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, SP: SimplexProcessor<Point = P>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, TL: Transform<P>, TR: Transform<P>,

Do intersection test on the given primitives

§Parameters:
  • left: left primitive
  • left_transform: model-to-world-transform for the left primitive
  • right: right primitive,
  • right_transform: model-to-world-transform for the right primitive
§Returns:

Will return a simplex if a collision was detected. For 2D, the simplex will be a triangle, for 3D, it will be a tetrahedron. The simplex will enclose the origin. If no collision was detected, None is returned.

Source

pub fn intersection_time_of_impact<P, PL, PR, TL, TR>( &self, left: &PL, left_transform: Range<&TL>, right: &PR, right_transform: Range<&TR>, ) -> Option<Contact<P>>
where P: EuclideanSpace<Scalar = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, SP: SimplexProcessor<Point = P>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, TL: Transform<P> + TranslationInterpolate<S>, TR: Transform<P> + TranslationInterpolate<S>,

Do time of impact intersection testing on the given primitives, and return a valid contact at the time of impact.

§Parameters:
  • left: left primitive
  • left_transform: model-to-world-transform for the left primitive
  • right: right primitive,
  • right_transform: model-to-world-transform for the right primitive
§Returns:

Will optionally return a contact manifold at the time of impact. If no collision was detected, None is returned.

Source

pub fn distance<P, PL, PR, TL, TR>( &self, left: &PL, left_transform: &TL, right: &PR, right_transform: &TR, ) -> Option<S>
where P: EuclideanSpace<Scalar = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, SP: SimplexProcessor<Point = P>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, TL: Transform<P>, TR: Transform<P>,

Compute the distance between the given primitives.

§Parameters:
  • left: left primitive
  • left_transform: model-to-world-transform for the left primitive
  • right: right primitive,
  • right_transform: model-to-world-transform for the right primitive
§Returns:

Will optionally return the distance between the objects. Will return None, if the objects are colliding.

Source

pub fn get_contact_manifold<P, PL, PR, TL, TR>( &self, simplex: &mut Vec<SupportPoint<P>>, left: &PL, left_transform: &TL, right: &PR, right_transform: &TR, ) -> Option<Contact<P>>
where P: EuclideanSpace<Scalar = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, TL: Transform<P>, TR: Transform<P>, SP: SimplexProcessor<Point = P>,

Given a GJK simplex that encloses the origin, compute the contact manifold.

Uses the EPA algorithm to find the contact information from the simplex.

Source

pub fn intersection<P, PL, PR, TL, TR>( &self, strategy: &CollisionStrategy, left: &PL, left_transform: &TL, right: &PR, right_transform: &TR, ) -> Option<Contact<P>>
where P: EuclideanSpace<Scalar = S>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, TL: Transform<P>, TR: Transform<P>, SP: SimplexProcessor<Point = P>,

Do intersection testing on the given primitives, and return the contact manifold.

§Parameters:
  • strategy: strategy to use, if CollisionOnly it will only return a boolean result, otherwise, EPA will be used to compute the exact contact point.
  • left: left primitive
  • left_transform: model-to-world-transform for the left primitive
  • right: right primitive,
  • right_transform: model-to-world-transform for the right primitive
§Returns:

Will optionally return a Contact if a collision was detected. In CollisionOnly mode, this contact will only be a boolean result. For FullResolution mode, the contact will contain a full manifold (collision normal, penetration depth and contact point).

Source

pub fn intersection_complex<P, PL, PR, TL, TR>( &self, strategy: &CollisionStrategy, left: &[(PL, TL)], left_transform: &TL, right: &[(PR, TR)], right_transform: &TR, ) -> Option<Contact<P>>
where P: EuclideanSpace<Scalar = S>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, TL: Transform<P>, TR: Transform<P>, SP: SimplexProcessor<Point = P>,

Do intersection test on the given complex shapes, and return the actual intersection point

§Parameters:
  • strategy: strategy to use, if CollisionOnly it will only return a boolean result, otherwise, EPA will be used to compute the exact contact point.
  • left: shape consisting of a slice of primitive + local-to-model-transform for each primitive,
  • left_transform: model-to-world-transform for the left shape
  • right: shape consisting of a slice of primitive + local-to-model-transform for each primitive,
  • right_transform: model-to-world-transform for the right shape
§Returns:

Will optionally return a Contact if a collision was detected. In CollisionOnly mode, this contact will only be a boolean result. For FullResolution mode, the contact will contain a full manifold (collision normal, penetration depth and contact point), for the contact with the highest penetration depth.

Source

pub fn distance_complex<P, PL, PR, TL, TR>( &self, left: &[(PL, TL)], left_transform: &TL, right: &[(PR, TR)], right_transform: &TR, ) -> Option<S>
where P: EuclideanSpace<Scalar = S>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, TL: Transform<P>, TR: Transform<P>, SP: SimplexProcessor<Point = P>,

Compute the distance between the given shapes.

§Parameters:
  • left: left shape
  • left_transform: model-to-world-transform for the left shape
  • right: right shape,
  • right_transform: model-to-world-transform for the right shape
§Returns:

Will optionally return the smallest distance between the objects. Will return None, if the objects are colliding.

Source

pub fn intersection_complex_time_of_impact<P, PL, PR, TL, TR>( &self, strategy: &CollisionStrategy, left: &[(PL, TL)], left_transform: Range<&TL>, right: &[(PR, TR)], right_transform: Range<&TR>, ) -> Option<Contact<P>>
where P: EuclideanSpace<Scalar = S>, P::Diff: Neg<Output = P::Diff> + InnerSpace + Zero + Array<Element = S>, PL: Primitive<Point = P>, PR: Primitive<Point = P>, TL: Transform<P> + TranslationInterpolate<S>, TR: Transform<P> + TranslationInterpolate<S>, SP: SimplexProcessor<Point = P>,

Do intersection time of impact test on the given complex shapes, and return the contact at the time of impact

§Parameters:
  • strategy: strategy to use, if CollisionOnly it will only return a boolean result, otherwise, a full contact manifold will be returned.
  • left: shape consisting of a slice of primitive + local-to-model-transform for each primitive,
  • left_transform: model-to-world-transform for the left shape
  • right: shape consisting of a slice of primitive + local-to-model-transform for each primitive,
  • right_transform: model-to-world-transform for the right shape
§Returns:

Will optionally return the contact if a collision was detected. In CollisionOnly mode, this contact will only be a time of impact. For FullResolution mode, the time of impact will be the earliest found among all shape primitives. Will return None if no collision was found.

Trait Implementations§

Source§

impl<SP: Debug, E: Debug, S: Debug> Debug for GJK<SP, E, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<SP, E, S> Freeze for GJK<SP, E, S>
where SP: Freeze, E: Freeze, S: Freeze,

§

impl<SP, E, S> RefUnwindSafe for GJK<SP, E, S>

§

impl<SP, E, S> Send for GJK<SP, E, S>
where SP: Send, E: Send, S: Send,

§

impl<SP, E, S> Sync for GJK<SP, E, S>
where SP: Sync, E: Sync, S: Sync,

§

impl<SP, E, S> Unpin for GJK<SP, E, S>
where SP: Unpin, E: Unpin, S: Unpin,

§

impl<SP, E, S> UnwindSafe for GJK<SP, E, S>
where SP: UnwindSafe, E: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.