Aabb

Struct Aabb 

Source
#[repr(C)]
pub struct Aabb { pub min: Vec3A, pub max: Vec3A, }
Expand description

An Axis-Aligned Bounding Box (AABB) represented by its minimum and maximum points.

Fields§

§min: Vec3A§max: Vec3A

Implementations§

Source§

impl Aabb

Source

pub const INVALID: Self

An invalid (empty) AABB with min set to the maximum possible value and max set to the minimum possible value.

Source

pub const LARGEST: Self

An infinite AABB with min set to negative infinity and max set to positive infinity.

Source

pub const INFINITY: Self

An infinite AABB with min set to negative infinity and max set to positive infinity.

Source

pub fn new(min: Vec3A, max: Vec3A) -> Self

Creates a new AABB with the given minimum and maximum points.

Source

pub fn from_point(point: Vec3A) -> Self

Creates a new AABB with both min and max set to the given point.

Source

pub fn from_points(points: &[Vec3A]) -> Self

Creates an AABB that bounds the given set of points.

Source

pub fn contains_point(&self, point: Vec3A) -> bool

Checks if the AABB contains the given point.

Source

pub fn extend(&mut self, point: Vec3A) -> &mut Self

Extends the AABB to include the given point.

Source

pub fn union(&self, other: &Self) -> Self

Returns the union of this AABB and another AABB.

Source

pub fn intersection(&self, other: &Self) -> Self

Returns the intersection of this AABB and another AABB.

The intersection of two AABBs is the overlapping region that is common to both AABBs. If the AABBs do not overlap, the resulting AABB will have min and max values that do not form a valid box (min will not be less than max).

Source

pub fn diagonal(&self) -> Vec3A

Returns the diagonal vector of the AABB.

Source

pub fn center(&self) -> Vec3A

Returns the center point of the AABB.

Source

pub fn center_axis(&self, axis: usize) -> f32

Returns the center coordinate of the AABB along a specific axis.

Source

pub fn largest_axis(&self) -> usize

Returns the index of the largest axis of the AABB.

Source

pub fn smallest_axis(&self) -> usize

Returns the index of the smallest axis of the AABB.

Source

pub fn half_area(&self) -> f32

Returns half the surface area of the AABB.

Source

pub fn surface_area(&self) -> f32

Returns the surface area of the AABB.

Source

pub fn empty() -> Self

Returns an empty AABB.

Source

pub fn valid(&self) -> bool

Checks if the AABB is valid (i.e., min <= max on all axes).

Source

pub fn intersect_aabb(&self, other: &Aabb) -> bool

Checks if this AABB intersects with another AABB.

Source

pub fn intersect_ray(&self, ray: &Ray) -> f32

Checks if this AABB intersects with a ray and returns the distance to the intersection point. Returns f32::INFINITY if there is no intersection.

Trait Implementations§

Source§

impl Boundable for Aabb

Source§

fn aabb(&self) -> Aabb

Source§

impl Clone for Aabb

Source§

fn clone(&self) -> Aabb

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 Aabb

Source§

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

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

impl Default for Aabb

Source§

fn default() -> Aabb

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

impl PartialEq for Aabb

Source§

fn eq(&self, other: &Aabb) -> 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 Zeroable for Aabb

Source§

fn zeroed() -> Self

Source§

impl Copy for Aabb

Source§

impl Pod for Aabb

Source§

impl StructuralPartialEq for Aabb

Auto Trait Implementations§

§

impl Freeze for Aabb

§

impl RefUnwindSafe for Aabb

§

impl Send for Aabb

§

impl Sync for Aabb

§

impl Unpin for Aabb

§

impl UnwindSafe for Aabb

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,