parry2d/bounding_volume/
aabb_cuboid.rs

1use crate::bounding_volume::Aabb;
2use crate::math::Pose;
3use crate::shape::Cuboid;
4use crate::utils::PoseOps;
5
6impl Cuboid {
7    /// Computes the world-space [`Aabb`] of this cuboid, transformed by `pos`.
8    #[inline]
9    pub fn aabb(&self, pos: &Pose) -> Aabb {
10        let center = pos.translation;
11        let ws_half_extents = pos.absolute_transform_vector(self.half_extents);
12
13        Aabb::from_half_extents(center, ws_half_extents)
14    }
15
16    /// Computes the local-space [`Aabb`] of this cuboid.
17    #[inline]
18    pub fn local_aabb(&self) -> Aabb {
19        Aabb::new(-self.half_extents, self.half_extents)
20    }
21}