parry3d/query/closest_points/
closest_points_ball_convex_polyhedron.rs

1use crate::math::{Isometry, Real};
2use crate::query::ClosestPoints;
3use crate::shape::{Ball, Shape};
4
5/// ClosestPoints between a ball and a convex polyhedron.
6///
7/// This function panics if the input shape does not implement
8/// both the ConvexPolyhedron and PointQuery traits.
9#[inline]
10pub fn closest_points_ball_convex_polyhedron(
11    pos12: &Isometry<Real>,
12    ball1: &Ball,
13    shape2: &(impl Shape + ?Sized),
14    prediction: Real,
15) -> ClosestPoints {
16    match crate::query::details::contact_ball_convex_polyhedron(pos12, ball1, shape2, prediction) {
17        Some(contact) => {
18            if contact.dist <= 0.0 {
19                ClosestPoints::Intersecting
20            } else {
21                ClosestPoints::WithinMargin(contact.point1, contact.point2)
22            }
23        }
24        None => ClosestPoints::Disjoint,
25    }
26}
27
28/// ClosestPoints between a convex polyhedron and a ball.
29///
30/// This function panics if the input shape does not implement
31/// both the ConvexPolyhedron and PointQuery traits.
32#[inline]
33pub fn closest_points_convex_polyhedron_ball(
34    pos12: &Isometry<Real>,
35    shape1: &(impl Shape + ?Sized),
36    ball2: &Ball,
37    prediction: Real,
38) -> ClosestPoints {
39    match crate::query::details::contact_convex_polyhedron_ball(pos12, shape1, ball2, prediction) {
40        Some(contact) => {
41            if contact.dist <= 0.0 {
42                ClosestPoints::Intersecting
43            } else {
44                ClosestPoints::WithinMargin(contact.point1, contact.point2)
45            }
46        }
47        None => ClosestPoints::Disjoint,
48    }
49}