pub struct BoundingBox<const N: usize> { /* private fields */ }Expand description
A hypercube in N-dimensional space representing a bounding box.
Implementations§
Source§impl<const N: usize> BoundingBox<N>
impl<const N: usize> BoundingBox<N>
Sourcepub fn new(min: NVector<N>, max: NVector<N>) -> Self
pub fn new(min: NVector<N>, max: NVector<N>) -> Self
Creates a new BoundingBox from a minimum and maximum NVector.
Sourcepub fn min(&self) -> &NVector<N>
pub fn min(&self) -> &NVector<N>
Returns the minimum of the BoundingBox.
Sourcepub fn max(&self) -> &NVector<N>
pub fn max(&self) -> &NVector<N>
Returns the maximum of the BoundingBox.
Sourcepub fn volume(&self) -> f32
pub fn volume(&self) -> f32
Returns the volume of the BoundingBox.
Sourcepub fn center(&self) -> NVector<N>
pub fn center(&self) -> NVector<N>
Returns the center of the BoundingBox.
Sourcepub fn contains(&self, point: &NVector<N>) -> bool
pub fn contains(&self, point: &NVector<N>) -> bool
Determine if an NVector is within the BoundingBox.
Sourcepub fn contains_tensor<B: Backend>(
&self,
points: Tensor<B, 2>,
) -> Tensor<B, 1, Bool>
pub fn contains_tensor<B: Backend>( &self, points: Tensor<B, 2>, ) -> Tensor<B, 1, Bool>
Determine if a set of points are within the BoundingBox.
Sourcepub fn corners(&self) -> impl Iterator<Item = NVector<N>>
pub fn corners(&self) -> impl Iterator<Item = NVector<N>>
Returns the corners of the BoundingBox as an iterator of NVectors.
Sourcepub fn sample(&self, rng: &mut impl Rng) -> NVector<N>
pub fn sample(&self, rng: &mut impl Rng) -> NVector<N>
Sample a random point within the BoundingBox.
Sourcepub fn sample_on_device<B: Backend>(
&self,
num_samples: usize,
rng: &mut impl Rng,
device: &B::Device,
) -> Tensor<B, 2, Float>
pub fn sample_on_device<B: Backend>( &self, num_samples: usize, rng: &mut impl Rng, device: &B::Device, ) -> Tensor<B, 2, Float>
Sample many random points within the BoundingBox on a given device.
Sourcepub fn split(&self) -> (BoundingBox<N>, BoundingBox<N>)
pub fn split(&self) -> (BoundingBox<N>, BoundingBox<N>)
Split a BoundingBox into two equally-sized BoundingBoxes along the longest axis
Sourcepub fn multisplit(&self, depth: usize) -> Vec<BoundingBox<N>>
pub fn multisplit(&self, depth: usize) -> Vec<BoundingBox<N>>
Subdivide a BoundingBox into a set of BoundingBoxes
This makes 2^(N * depth) leaf BoundingBoxes.
Sourcepub fn point_in_bounds(&self, point: &NVector<N>) -> bool
pub fn point_in_bounds(&self, point: &NVector<N>) -> bool
Determine if a point is within the BoundingBox.
Sourcepub fn points_in_bounds<B: Backend>(
&self,
points: Tensor<B, 2, Float>,
) -> Tensor<B, 1, Bool>
pub fn points_in_bounds<B: Backend>( &self, points: Tensor<B, 2, Float>, ) -> Tensor<B, 1, Bool>
Determine if a set of points are within the BoundingBox.
Trait Implementations§
Source§impl<const N: usize> Clone for BoundingBox<N>
impl<const N: usize> Clone for BoundingBox<N>
Source§fn clone(&self) -> BoundingBox<N>
fn clone(&self) -> BoundingBox<N>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<const N: usize> Debug for BoundingBox<N>
impl<const N: usize> Debug for BoundingBox<N>
Source§impl<const N: usize, B: Backend> IntoRegion<N, B> for BoundingBox<N>
impl<const N: usize, B: Backend> IntoRegion<N, B> for BoundingBox<N>
fn into_region(self, device: B::Device) -> Region<N, B>
Source§impl<const N: usize> PartialEq for BoundingBox<N>
impl<const N: usize> PartialEq for BoundingBox<N>
impl<const N: usize> Copy for BoundingBox<N>
impl<const N: usize> StructuralPartialEq for BoundingBox<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for BoundingBox<N>
impl<const N: usize> RefUnwindSafe for BoundingBox<N>
impl<const N: usize> Send for BoundingBox<N>
impl<const N: usize> Sync for BoundingBox<N>
impl<const N: usize> Unpin for BoundingBox<N>
impl<const N: usize> UnwindSafe for BoundingBox<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more