parry3d_f64/bounding_volume/aabb_cuboid.rs
1use crate::bounding_volume::Aabb;
2use crate::math::{Isometry, Point, Real};
3use crate::shape::Cuboid;
4use crate::utils::IsometryOps;
5
6impl Cuboid {
7 /// Computes the world-space [`Aabb`] of this cuboid, transformed by `pos`.
8 #[inline]
9 pub fn aabb(&self, pos: &Isometry<Real>) -> Aabb {
10 let center = Point::from(pos.translation.vector);
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 let half_extents = Point::from(self.half_extents);
20
21 Aabb::new(-half_extents, half_extents)
22 }
23}