parry3d/query/distance/
distance_ball_convex_polyhedron.rs1use crate::math::{Isometry, Point, Real};
2use crate::shape::{Ball, Shape};
3
4#[inline]
9pub fn distance_ball_convex_polyhedron(
10 pos12: &Isometry<Real>,
11 ball1: &Ball,
12 shape2: &(impl Shape + ?Sized),
13) -> Real {
14 distance_convex_polyhedron_ball(&pos12.inverse(), shape2, ball1)
15}
16
17#[inline]
22pub fn distance_convex_polyhedron_ball(
23 pos12: &Isometry<Real>,
24 shape1: &(impl Shape + ?Sized),
25 ball2: &Ball,
26) -> Real {
27 let center2_1 = Point::from(pos12.translation.vector);
28 let proj = shape1.project_local_point(¢er2_1, true);
29 (na::distance(&proj.point, ¢er2_1) - ball2.radius).max(0.0)
30}