parry3d/bounding_volume/
aabb_ball.rs1use crate::bounding_volume::Aabb;
2use crate::math::{Isometry, Point, Real, Vector};
3use crate::shape::Ball;
4
5#[inline]
7pub fn ball_aabb(center: &Point<Real>, radius: Real) -> Aabb {
8 Aabb::new(
9 *center + Vector::repeat(-radius),
10 *center + Vector::repeat(radius),
11 )
12}
13
14#[inline]
16pub fn local_ball_aabb(radius: Real) -> Aabb {
17 let half_extents = Point::from(Vector::repeat(radius));
18
19 Aabb::new(-half_extents, half_extents)
20}
21
22impl Ball {
23 #[inline]
25 pub fn aabb(&self, pos: &Isometry<Real>) -> Aabb {
26 ball_aabb(&Point::<Real>::from(pos.translation.vector), self.radius)
27 }
28
29 #[inline]
31 pub fn local_aabb(&self) -> Aabb {
32 local_ball_aabb(self.radius)
33 }
34}