ncollide3d/bounding_volume/
bounding_sphere_utils.rsuse crate::math::Point;
use crate::utils;
use na::{self, RealField};
#[inline]
pub fn point_cloud_bounding_sphere_with_center<N: RealField + Copy>(
pts: &[Point<N>],
center: Point<N>,
) -> (Point<N>, N) {
let mut sqradius = na::zero();
for pt in pts.iter() {
let distance_squared = na::distance_squared(pt, ¢er);
if distance_squared > sqradius {
sqradius = distance_squared
}
}
(center, sqradius.sqrt())
}
#[inline]
pub fn point_cloud_bounding_sphere<N: RealField + Copy>(pts: &[Point<N>]) -> (Point<N>, N) {
point_cloud_bounding_sphere_with_center(pts, utils::center(pts))
}