Constructs the smallest AABB fitting around all the given points ``` use crate::splashsurf_lib::Aabb3d; use nalgebra::Vector3; assert_eq!( Aabb3d:: ::from_points(&[]), Aabb3d:: ::zeros() ); assert_eq!( Aabb3d:: ::from_points(&[Vector3::new(1.0, 1.0, 1.0)]), Aabb3d:: ::from_point(Vector3::new(1.0, 1.0, 1.0)) ); let aabb = Aabb3d:: ::from_points(&[ Vector3::new(1.0, 1.0, 1.0),
(points: &[SVector<R, D>])
| 100 | /// assert_eq!(aabb.max(), &Vector3::new(1.0, 3.0, 5.0)); |
| 101 | /// ``` |
| 102 | pub fn from_points(points: &[SVector<R, D>]) -> Self { |
| 103 | let mut point_iter = points.iter(); |
| 104 | if let Some(first_point) = point_iter.next().cloned() { |
| 105 | let mut aabb = Self::from_point(first_point); |
| 106 | for next_point in point_iter { |
| 107 | aabb.join_with_point(next_point) |
| 108 | } |
| 109 | aabb |
| 110 | } else { |
| 111 | Self::zeros() |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /// Tries to convert the AABB from one real type to another real type, returns None if conversion fails |
| 116 | pub fn try_convert<T>(&self) -> Option<AxisAlignedBoundingBox<T, D>> |
nothing calls this directly
no test coverage detected