Function geometry_tools::bounding::calculate_aabb_from_points[][src]

pub fn calculate_aabb_from_points(points: &[Vec3A]) -> (Vec3A, Vec3A)
Expand description

Calculates an axis-aligned bounding box (abbreviated aabb) of the form (min_xyz, max_xyz) containing all the specified points.

use geometry_tools::calculate_aabb_from_points;
use glam::Vec3A;

let (min, max) = calculate_aabb_from_points(&[
    Vec3A::new(-1f32,  1f32,  2f32),
    Vec3A::new( 0f32,  2f32,  1f32),
    Vec3A::new( 2f32, -1f32, -1f32),
]);
assert_eq!(min, Vec3A::new(-1f32, -1f32, -1f32));
assert_eq!(max, Vec3A::new( 2f32,  2f32,  2f32));

If points is empty, both min_xyz and max_xyz will be zero.

let aabb = calculate_aabb_from_points(&[]);
assert_eq!((Vec3A::ZERO, Vec3A::ZERO), aabb);