Function geometry_tools::bounding::calculate_bounding_sphere_from_points [−][src]
pub fn calculate_bounding_sphere_from_points(points: &[Vec3A]) -> (Vec3A, f32)
Expand description
Calculates a bounding sphere of the form (center, radius)
that containts all the specified points.
The returned result will contain all points but may be larger than the optimal solution.
use geometry_tools::calculate_bounding_sphere_from_points; use glam::Vec3A; let points = vec![ Vec3A::new(0f32, -1f32, -0f32), Vec3A::new(0f32, 0f32, 0f32), Vec3A::new(0f32, 1f32, 0f32), ]; let (center, radius) = calculate_bounding_sphere_from_points(&points); assert_eq!(Vec3A::ZERO, center); assert_eq!(1f32, radius);
If points
is empty, the center and radius will both be zero.
let bounding_sphere = calculate_bounding_sphere_from_points(&[]); assert_eq!((Vec3A::ZERO, 0f32), bounding_sphere);