use num::Zero; use alga::linear::Translation; use na; use query::algorithms::gjk; use query::algorithms::{Simplex, JohnsonSimplex, VoronoiSimplex2, VoronoiSimplex3}; use shape::{self, SupportMap}; use math::{Isometry, Point}; /// Distance between support-mapped shapes. pub fn support_map_against_support_map
( m1: &M, g1: &G1, m2: &M, g2: &G2, ) -> P::Real where P: Point, M: Isometry
, G1: SupportMap
, G2: SupportMap
,
{
if na::dimension:: (
m1: &M,
g1: &G1,
m2: &M,
g2: &G2,
simplex: &mut S,
init_dir: Option ,
S: Simplex ,
G1: SupportMap ,
G2: SupportMap ,
{
let mut dir = match init_dir {
// FIXME: or m2.translation - m1.translation ?
None => m1.translation().to_vector() - m2.translation().to_vector(),
Some(dir) => dir,
};
if dir.is_zero() {
dir[0] = na::one();
}
simplex.reset(*shape::cso_support_point(m1, g1, m2, g2, dir).point());
gjk::distance(m1, g1, m2, g2, simplex)
}