Struct octree::BoundingBox
source · pub struct BoundingBox { /* private fields */ }
Expand description
Bounding box defines a 3D space.
Implementations§
source§impl BoundingBox
impl BoundingBox
sourcepub fn new<L>(points: Vec<&L>) -> Selfwhere
L: Locatable,
pub fn new<L>(points: Vec<&L>) -> Selfwhere L: Locatable,
Construct a new BoundingBox which can hold all given points.
Example
use octree::point::Point3D;
use octree::BoundingBox;
let point1 = Point3D::new(0.0, 0.0, 0.0);
let point2 = Point3D::new(10.0, 10.0, 10.0);
let bounding_box = BoundingBox::new(vec![point1, point2].iter().collect());
sourcepub fn covers(&self, point: &[f32; 3]) -> bool
pub fn covers(&self, point: &[f32; 3]) -> bool
Check if a point can be covered by this BoundingBox.
Example
use octree::point::Point3D;
use octree::{BoundingBox, Locatable};
let point1 = Point3D::new(0.0, 0.0, 0.0);
let point2 = Point3D::new(10.0, 10.0, 10.0);
let point3 = Point3D::new(5.0, 5.0, 5.0);
let point4 = Point3D::new(20.0, 20.0, 20.0);
let bounding_box = BoundingBox::new(vec![point1, point2].iter().collect());
assert!(bounding_box.covers(&point3.get_location()));
assert!(!bounding_box.covers(&point4.get_location()));
sourcepub fn overlaps(&self, other: &BoundingBox) -> bool
pub fn overlaps(&self, other: &BoundingBox) -> bool
Check if two BoundingBoxes overlap.
sourcepub fn get_centre(&self) -> [f32; 3]
pub fn get_centre(&self) -> [f32; 3]
Getter for BoundingBox centre coordination.
sourcepub fn get_min(&self) -> &[f32; 3]
pub fn get_min(&self) -> &[f32; 3]
Getter for BoundingBox min corner coordination.
sourcepub fn get_max(&self) -> &[f32; 3]
pub fn get_max(&self) -> &[f32; 3]
Getter for BoundingBox max corner coordination.
sourcepub fn split(&self) -> [Self; 8]
pub fn split(&self) -> [Self; 8]
Split the BoundingBox into 8 sub BoundingBoxes.
Trait Implementations§
source§impl Clone for BoundingBox
impl Clone for BoundingBox
source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for BoundingBox
impl Debug for BoundingBox
source§impl Default for BoundingBox
impl Default for BoundingBox
source§fn default() -> Self
fn default() -> Self
Construct a default BoundingBox, covers the whole space which can be represented by f32.
source§impl PartialEq<BoundingBox> for BoundingBox
impl PartialEq<BoundingBox> for BoundingBox
source§fn eq(&self, other: &BoundingBox) -> bool
fn eq(&self, other: &BoundingBox) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.