parry3d/bounding_volume/
aabb_capsule.rs

1use crate::bounding_volume::Aabb;
2use crate::math::{Isometry, Real, Vector};
3use crate::shape::Capsule;
4
5impl Capsule {
6    /// The axis-aligned bounding box of this capsule.
7    #[inline]
8    pub fn aabb(&self, pos: &Isometry<Real>) -> Aabb {
9        self.transform_by(pos).local_aabb()
10    }
11
12    /// The axis-aligned bounding box of this capsule.
13    #[inline]
14    pub fn local_aabb(&self) -> Aabb {
15        let a = self.segment.a;
16        let b = self.segment.b;
17        let mins = a.coords.inf(&b.coords) - Vector::repeat(self.radius);
18        let maxs = a.coords.sup(&b.coords) + Vector::repeat(self.radius);
19        Aabb::new(mins.into(), maxs.into())
20    }
21}