Struct AxisAlignedBoundingBox

Source
pub struct AxisAlignedBoundingBox { /* private fields */ }
Expand description

A bounding box that aligns with the x, y and z axes.

Implementations§

Source§

impl AxisAlignedBoundingBox

Source

pub const EMPTY: AxisAlignedBoundingBox

An empty bounding box.

Source

pub const INFINITE: AxisAlignedBoundingBox

An infinitely large bounding box.

Source

pub fn new_with_positions(positions: &[Vector3<f32>]) -> AxisAlignedBoundingBox

Constructs a new bounding box and expands it such that all of the given positions are contained inside the bounding box.

Source

pub fn new_with_transformed_positions( positions: &[Vector3<f32>], transformation: &Matrix4<f32>, ) -> AxisAlignedBoundingBox

Constructs a new bounding box and expands it such that all of the given positions transformed with the given transformation are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.

Source

pub fn is_empty(&self) -> bool

Returns true if the bounding box is empty (ie. constructed by AxisAlignedBoundingBox::EMPTY).

Source

pub fn is_infinite(&self) -> bool

Returns true if the bounding box is infinitely large (ie. constructed by AxisAlignedBoundingBox::INFINITE).

Source

pub fn min(&self) -> Vector3<f32>

Get the minimum coordinate of the bounding box.

Source

pub fn max(&self) -> Vector3<f32>

Get the maximum coordinate of the bounding box.

Source

pub fn center(&self) -> Vector3<f32>

Get the center of the bounding box.

Source

pub fn size(&self) -> Vector3<f32>

Get the size of the bounding box.

Source

pub fn expand(&mut self, positions: &[Vector3<f32>])

Expands the bounding box such that all of the given positions are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.

Source

pub fn expand_with_transformation( &mut self, positions: &[Vector3<f32>], transformation: &Matrix4<f32>, )

Expands the bounding box such that all of the given positions transformed with the given transformation are contained inside the bounding box. A position consisting of an x, y and z coordinate corresponds to three consecutive value in the positions array.

Source

pub fn expand_with_aabb(&mut self, other: &AxisAlignedBoundingBox)

Expand the bounding box such that it also contains the given other bounding box.

Source

pub fn transform(&mut self, transformation: &Matrix4<f32>)

Transforms the bounding box by the given transformation.

Note: Use new_with_transformed_positions instead of new_with_positions followed by this method to create a more tight bounding box.

Source

pub fn distance(&self, position: &Vector3<f32>) -> f32

The distance from position to the point in this bounding box that is closest to position.

Source

pub fn distance_max(&self, position: &Vector3<f32>) -> f32

The distance from position to the point in this bounding box that is furthest away from position.

Trait Implementations§

Source§

impl Clone for AxisAlignedBoundingBox

Source§

fn clone(&self) -> AxisAlignedBoundingBox

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AxisAlignedBoundingBox

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Copy for AxisAlignedBoundingBox

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.