parry3d/query/closest_points/
closest_points_shape_shape.rs

1use crate::math::{Isometry, Real};
2use crate::query::{ClosestPoints, DefaultQueryDispatcher, QueryDispatcher, Unsupported};
3use crate::shape::Shape;
4
5/// Computes the pair of closest points between two shapes.
6///
7/// Returns `ClosestPoints::Disjoint` if the objects are separated by a distance greater than `max_dist`.
8/// The result points in `ClosestPoints::WithinMargin` are expressed in world-space.
9pub fn closest_points(
10    pos1: &Isometry<Real>,
11    g1: &dyn Shape,
12    pos2: &Isometry<Real>,
13    g2: &dyn Shape,
14    max_dist: Real,
15) -> Result<ClosestPoints, Unsupported> {
16    let pos12 = pos1.inv_mul(pos2);
17    DefaultQueryDispatcher
18        .closest_points(&pos12, g1, g2, max_dist)
19        .map(|res| res.transform_by(pos1, pos2))
20}