parry3d/query/distance/
distance_halfspace_support_map.rs

1use crate::math::{Pose, Real};
2use crate::shape::HalfSpace;
3use crate::shape::SupportMap;
4
5/// Distance between a halfspace and a support-mapped shape.
6pub fn distance_halfspace_support_map<G: ?Sized + SupportMap>(
7    pos12: &Pose,
8    halfspace: &HalfSpace,
9    other: &G,
10) -> Real {
11    let deepest = other.support_point_toward(pos12, -halfspace.normal);
12    halfspace.normal.dot(deepest).max(0.0)
13}
14
15/// Distance between a support-mapped shape and a halfspace.
16pub fn distance_support_map_halfspace<G: ?Sized + SupportMap>(
17    pos12: &Pose,
18    other: &G,
19    halfspace: &HalfSpace,
20) -> Real {
21    distance_halfspace_support_map(&pos12.inverse(), halfspace, other)
22}