parry3d_f64/bounding_volume/
bounding_sphere_cylinder.rs

1use crate::bounding_volume::BoundingSphere;
2use crate::math::{ComplexField, Pose, Real, Vector};
3use crate::shape::Cylinder;
4
5impl Cylinder {
6    /// Computes the world-space bounding sphere of this cylinder, transformed by `pos`.
7    #[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    /// Computes the local-space bounding sphere of this cylinder.
14    #[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}