parry3d/bounding_volume/
bounding_sphere_cylinder.rs1use crate::bounding_volume::BoundingSphere;
2use crate::math::{Isometry, Point, Real};
3use crate::shape::Cylinder;
4use na::ComplexField;
5
6impl Cylinder {
7 #[inline]
9 pub fn bounding_sphere(&self, pos: &Isometry<Real>) -> BoundingSphere {
10 let bv: BoundingSphere = self.local_bounding_sphere();
11 bv.transform_by(pos)
12 }
13
14 #[inline]
16 pub fn local_bounding_sphere(&self) -> BoundingSphere {
17 let radius =
18 ComplexField::sqrt(self.radius * self.radius + self.half_height * self.half_height);
19
20 BoundingSphere::new(Point::origin(), radius)
21 }
22}