Struct Proximity

Source
pub struct Proximity {
    pub distance: f64,
    pub half_axis: Vector3<f64>,
    pub midpoint: Point3<f64>,
    pub normal: Unit3<f64>,
}
Expand description

Result of a proximity query between a pair of bounded objects.

Note that the axis vector points from object A to object B, while the normal vector points from object B to object A, but they should be parallel when the axis vector is non-zero.

Fields§

§distance: f64

Signed distance.

A positive distance indicates the separating distance for a disjoint result, and a negative distance indicates a penetration depth of an intersection result.

§half_axis: Vector3<f64>

Non-normalized vector pointing along the axis of separation or penetration from object A to object B.

For a disjoint configuration, adding this vector to the midpoint gives the nearest point on object B and subtracting this vector from the midpoint gives the nearest point on object A. Translating object A by this vector and translating objet B by its inverse will bring the objects into contact.

For an intersecting configuration, translating object A by this vector and translating object B by its inverse will resolve the inter-penetration.

Note this vector can be zero if the objects are in contact.

§midpoint: Point3<f64>

Indicates the midpoint of the proximity query

§normal: Unit3<f64>

The unit normal to the separating plane directed from object B to object A

Implementations§

Source§

impl Proximity

Source

pub fn query<A, B>(object_a: &A, object_b: &B) -> Self
where A: Bounded, B: Bounded,

Proximity query.

§Examples

Capsule v. capsule

By convention if the axes of capsules A and B intersect, the +X axis will be chosen for the axis vector and normal:

let a = object::Static {
  position:   component::Position ([0.0, 0.0, 1.0].into()),
  bound:      component::Bound (shape::Bounded::from (
    shape::Capsule::noisy (2.0, 3.0)).into()),
  material:   component::MATERIAL_STONE,
  collidable: true
};
let b = object::Static {
  position:   component::Position ([0.0, 0.0, -1.0].into()),
  bound:      component::Bound (shape::Bounded::from (
    shape::Capsule::noisy (1.0, 2.0)).into()),
  material:   component::MATERIAL_STONE,
  collidable: true
};
assert_eq!(
  Proximity::query (&a, &b),
  Proximity {
    distance:  -3.0,
    half_axis: [ 1.5, 0.0,  0.0].into(),
    normal:    math::Unit3::axis_x(),
    midpoint:  [-0.5, 0.0, -0.5].into()
  }
);
Source

pub fn relation(&self) -> Relation

Source

pub fn constraint_planar(&self) -> Planar

Source

pub fn query_sphere_sphere( position_a: &Point3<f64>, sphere_a: &Sphere<f64>, position_b: &Point3<f64>, sphere_b: &Sphere<f64>, ) -> Self

Source

pub fn query_capsule_capsule( position_a: &Point3<f64>, capsule_a: &Capsule<f64>, position_b: &Point3<f64>, capsule_b: &Capsule<f64>, ) -> Self

Source

pub fn query_cuboid_cuboid( position_a: &Point3<f64>, cuboid_a: &Cuboid<f64>, position_b: &Point3<f64>, cuboid_b: &Cuboid<f64>, ) -> Self

Source

pub fn query_sphere_capsule( position_a: &Point3<f64>, sphere_a: &Sphere<f64>, position_b: &Point3<f64>, capsule_b: &Capsule<f64>, ) -> Self

Source

pub fn query_sphere_cuboid( position_a: &Point3<f64>, sphere_a: &Sphere<f64>, position_b: &Point3<f64>, cuboid_b: &Cuboid<f64>, ) -> Self

Source

pub fn query_sphere_orthant( position_a: &Point3<f64>, sphere_a: &Sphere<f64>, position_b: &Point3<f64>, orthant_b: &Orthant, ) -> Self

Source

pub fn query_capsule_cuboid( position_a: &Point3<f64>, capsule_a: &Capsule<f64>, position_b: &Point3<f64>, cuboid_b: &Cuboid<f64>, ) -> Self

Source

pub fn query_capsule_orthant( position_a: &Point3<f64>, capsule_a: &Capsule<f64>, position_b: &Point3<f64>, orthant_b: &Orthant, ) -> Self

Source

pub fn query_cuboid_orthant( position_a: &Point3<f64>, cuboid_a: &Cuboid<f64>, position_b: &Point3<f64>, orthant_b: &Orthant, ) -> Self

Trait Implementations§

Source§

impl Clone for Proximity

Source§

fn clone(&self) -> Proximity

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Proximity

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Proximity> for Planar

Source§

fn from(proximity: Proximity) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Proximity

Source§

fn eq(&self, other: &Proximity) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Proximity> for Contact

Source§

type Error = ()

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

fn try_from(proximity: Proximity) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Proximity> for Intersection

Source§

type Error = Proximity

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

fn try_from(proximity: Proximity) -> Result<Self, Proximity>

Performs the conversion.
Source§

impl StructuralPartialEq for Proximity

Auto Trait Implementations§

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.