MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / from_points

Method from_points

splashsurf_lib/src/aabb.rs:102–113  ·  view source on GitHub ↗

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>])

Source from the content-addressed store, hash-verified

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>>

Callers

nothing calls this directly

Calls 3

join_with_pointMethod · 0.80
iterMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected