parry3d/bounding_volume/
bounding_sphere_cone.rs1use crate::bounding_volume::BoundingSphere;
2use crate::math::{ComplexField, Pose, Real, Vector};
3use crate::shape::Cone;
4
5impl Cone {
6 #[inline]
8 pub fn bounding_sphere(&self, pos: &Pose) -> BoundingSphere {
9 let bv: BoundingSphere = self.local_bounding_sphere();
10 bv.transform_by(pos)
11 }
12
13 #[inline]
15 pub fn local_bounding_sphere(&self) -> BoundingSphere {
16 let radius = <Real as ComplexField>::sqrt(
17 self.radius * self.radius + self.half_height * self.half_height,
18 );
19
20 BoundingSphere::new(Vector::ZERO, radius)
21 }
22}