1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
use crate::math::{Isometry, Real};
use crate::query::ClosestPoints;
use crate::shape::Cuboid;

/// Distance between two cuboids.
#[inline]
pub fn distance_cuboid_cuboid(pos12: &Isometry<Real>, cuboid1: &Cuboid, cuboid2: &Cuboid) -> Real {
    match crate::query::details::closest_points_cuboid_cuboid(pos12, cuboid1, cuboid2, Real::MAX) {
        ClosestPoints::WithinMargin(p1, p2) => na::distance(&p1, &(pos12 * p2)),
        _ => 0.0,
    }
}