BoundingBox

Struct BoundingBox 

Source
pub struct BoundingBox {
    pub min: Vec3,
    pub max: Vec3,
}
Expand description

A 3-dimensional axis-aligned bounding box

Fields§

§min: Vec3

Bounding box minimum (inclusive).

§max: Vec3

Bounding box maximum (inclusive).

Implementations§

Source§

impl BoundingBox

Source

pub const ZERO: BoundingBox

A BoundingBox that only contains Vec3::ZERO.

Source

pub fn nothing() -> BoundingBox

A BoundingBox that contains no points.

This is useful as the seed for bounding bounding boxes.

Source

pub fn everything() -> BoundingBox

A BoundingBox that contains every point.

Source

pub fn from_min_max(min: Vec3, max: Vec3) -> BoundingBox

Create a bounding box from a minimum and maximum position.

Source

pub fn from_min_size(min: Vec3, size: Vec3) -> BoundingBox

Source

pub fn from_center_size(center: Vec3, size: Vec3) -> BoundingBox

Create a bounding box from a center position and a size.

Source

pub fn from_points(points: impl Iterator<Item = Vec3>) -> BoundingBox

Create a bounding box from an iterator of points that the bounding box will cover.

Source

pub fn center(&self) -> Vec3

Returns the center point of the bounding box.

Source

pub fn size(&self) -> Vec3

Returns the 3D axis size of the bounding box.

Source

pub fn half_size(&self) -> Vec3

Returns half the size (similar to a radius).

Source

pub fn volume(&self) -> f32

Only correct for positively sized boxes.

Source

pub fn is_something(&self) -> bool

True if and only if there is at least one point for which bb.contains(point) is true.

Will return true if Self::min == Self::max. The opposite of is_nothing().

Source

pub fn is_nothing(&self) -> bool

True if and only if there is no point for which bb.contains(point) is true.

The opposite of is_something().

Source

pub fn is_point(&self) -> bool

True if this box contains exactly one point.

true if Self::min == Self::max.

Source

pub fn is_finite(&self) -> bool

Returns true if, and only if, all elements are finite.

If any element is either NaN, positive or negative infinity, this will return false.

Source

pub fn is_nan(&self) -> bool

Returns true if any elements are NaN.

Source

pub fn corners(&self) -> [Vec3; 8]

The eight corners of this bounding box.

Source

pub fn bounding_sphere_radius(&self) -> f32

The minimum radius of a sphere, centered at the origin, fully containing the box.

Requires a well-formed box for the result to be valid.

Source

pub fn centered_bounding_sphere_radius(&self) -> f32

The minimum radius of a sphere, centered at the bounding box, fully containing the box.

Requires a well-formed box for the result to be valid.

Source

pub fn edges(&self) -> [[Vec3; 2]; 12]

The twelve edges of this bounding box.

Source

pub fn extend(&mut self, pos: Vec3)

Enlarge the box to include this point.

Source

pub fn union(self, other: BoundingBox) -> BoundingBox

Source

pub fn intersection(self, other: BoundingBox) -> BoundingBox

Returns the smallest volume that is covered by both self and other, or Self::nothing if the boxes are disjoint.

Source

pub fn contains(&self, point: Vec3) -> bool

Returns true if the point is within (or on the edge of) the box.

Source

pub fn expanded(&self, padding: Vec3) -> BoundingBox

Expand with this much padding on each side.

Source

pub fn translated(&self, translation: Vec3) -> BoundingBox

Translate (move) the box by this much.

Source

pub fn rotated_around_origin(&self, q: &Quat) -> BoundingBox

Return a bounding box that contains this box after it has been rotated around Vec3::ZERO.

Note that the rotated bounding box is very likely larger than the original, since it must be large enough to contain the now rotated box.

Source

pub fn transform_iso(&self, m: &IsoTransform) -> BoundingBox

Return a bounding box that contains this box after it has been transformed.

Note that the rotated bounding box is very likely larger than the original, since it must be large enough to contain the now rotated box.

Source

pub fn transform_affine3(&self, m: &Affine3A) -> BoundingBox

Return a bounding box that contains this box after it has been transformed.

Note that the rotated bounding box is very likely larger than the original, since it must be large enough to contain the now rotated box.

Source

pub fn transform_conformal3(&self, m: &Conformal3) -> BoundingBox

Return a bounding box that contains this box after it has been transformed.

Note that the rotated bounding box is very likely larger than the original, since it must be large enough to contain the now rotated box.

Trait Implementations§

Source§

impl Clone for BoundingBox

Source§

fn clone(&self) -> BoundingBox

Returns a duplicate 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 BoundingBox

Source§

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

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

impl Default for BoundingBox

Source§

fn default() -> BoundingBox

Returns the “default value” for a type. Read more
Source§

impl PartialEq for BoundingBox

Source§

fn eq(&self, other: &BoundingBox) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for BoundingBox

Source§

impl StructuralPartialEq for BoundingBox

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.