[][src]Struct linear_sim::collision::proximity::Proximity

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

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

Methods

impl Proximity[src]

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

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
};
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
};
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()
  }
);

pub fn relation(&self) -> Relation[src]

pub fn constraint_planar(&self) -> Planar[src]

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

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

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

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

Trait Implementations

impl PartialEq<Proximity> for Proximity[src]

impl Clone for Proximity[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Proximity[src]

impl TryFrom<Proximity> for Intersection[src]

type Error = Proximity

The type returned in the event of a conversion error.

Auto Trait Implementations

impl Send for Proximity

impl Sync for Proximity

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self