use std::mem; use math::Point; use na::{Real, Unit}; /// Geometric description of a contact. #[derive(Debug, PartialEq, Clone)] pub struct Contact { /// Position of the contact on the first object. The position is expressed in world space. pub world1: P, /// Position of the contact on the second object. The position is expressed in world space. pub world2: P, /// Contact normal pub normal: Unit, /// Penetration depth pub depth: P::Real, } impl Contact

{ /// Creates a new contact. #[inline] pub fn new(world1: P, world2: P, normal: Unit, depth: P::Real) -> Contact

{ Contact { world1: world1, world2: world2, normal: normal, depth: depth, } } } impl Contact

{ /// Reverts the contact normal and swaps `world1` and `world2`. #[inline] pub fn flip(&mut self) { mem::swap(&mut self.world1, &mut self.world2); self.normal = -self.normal; } } /// The prediction parameters for contact determination.n pub struct ContactPrediction { /// The linear prediction. pub linear: N, /// The angular regularization for the first solid. pub angular1: N, /// The angular regularization for the second solid. pub angular2: N, } impl ContactPrediction { /// Initialize prediction parameters. pub fn new(linear: N, angular1: N, angular2: N) -> Self { ContactPrediction { linear, angular1, angular2 } } }