Skip to main content

axis_aligned_bounding_box

Function axis_aligned_bounding_box 

Source
pub fn axis_aligned_bounding_box(
    points: &ArrayView2<'_, f64>,
) -> SpatialResult<AABB>
Expand description

Compute the axis-aligned bounding box of a set of 2D points

§Arguments

  • points - A 2D array of points (n x 2)

§Returns

  • SpatialResult<AABB> - The axis-aligned bounding box

§Examples

use scirs2_spatial::computational_geometry::bounding::axis_aligned_bounding_box;
use scirs2_core::ndarray::array;

let points = array![[0.0, 1.0], [2.0, 3.0], [1.0, 0.5]];
let aabb = axis_aligned_bounding_box(&points.view()).expect("Operation failed");
assert!((aabb.min[0] - 0.0).abs() < 1e-10);
assert!((aabb.max[0] - 2.0).abs() < 1e-10);