parry3d/query/point/
point_bounding_sphere.rs

1use crate::bounding_volume::BoundingSphere;
2use crate::math::{Point, Real};
3use crate::query::{PointProjection, PointQuery};
4use crate::shape::{Ball, FeatureId};
5
6impl PointQuery for BoundingSphere {
7    #[inline]
8    fn project_local_point(&self, pt: &Point<Real>, solid: bool) -> PointProjection {
9        let centered_pt = pt - self.center().coords;
10        let mut proj = Ball::new(self.radius()).project_local_point(&centered_pt, solid);
11
12        proj.point += self.center().coords;
13        proj
14    }
15
16    #[inline]
17    fn project_local_point_and_get_feature(
18        &self,
19        pt: &Point<Real>,
20    ) -> (PointProjection, FeatureId) {
21        (self.project_local_point(pt, false), FeatureId::Face(0))
22    }
23
24    #[inline]
25    fn distance_to_local_point(&self, pt: &Point<Real>, solid: bool) -> Real {
26        let centered_pt = pt - self.center().coords;
27        Ball::new(self.radius()).distance_to_local_point(&centered_pt, solid)
28    }
29
30    #[inline]
31    fn contains_local_point(&self, pt: &Point<Real>) -> bool {
32        let centered_pt = pt - self.center().coords;
33        Ball::new(self.radius()).contains_local_point(&centered_pt)
34    }
35}