alloy::geometry

Struct AABB

source
pub struct AABB { /* private fields */ }
Expand description

Axis-aligned bounding box

Implementations§

source§

impl AABB

source

pub fn from_points(p0: &Point3, p1: &Point3) -> Self

Create a new axis-aligned bounding box

source

pub const fn from_corners(top_left: &Point3, bottom_right: &Point3) -> Self

Create a new axis-aligned bounding box

source§

impl AABB

source

pub const TOP_NORMAL: Vector3 = Vector3::UNIT_Y

Get the normal for the top of the box.

source

pub const BOTTOM_NORMAL: Vector3 = Vector3::NEG_UNIT_Y

Get the normal for the bottom of the box.

source

pub const FRONT_NORMAL: Vector3 = Vector3::UNIT_Z

Get the normal for the front of the box.

source

pub const BACK_NORMAL: Vector3 = Vector3::NEG_UNIT_Z

Get the normal for the back of the box.

source

pub const LEFT_NORMAL: Vector3 = Vector3::NEG_UNIT_X

Get the normal for the left of the box.

source

pub const RIGHT_NORMAL: Vector3 = Vector3::UNIT_X

Get the normal for the right of the box.

source

pub const fn top_plane(&self) -> Plane

Get the top-left corner of the bounding box

source

pub const fn bottom_plane(&self) -> Plane

Get the bottom-right corner of the bounding box

source

pub const fn front_plane(&self) -> Plane

Get the front plane of the bounding box

source

pub const fn back_plane(&self) -> Plane

Get the back plane of the bounding box

source

pub fn left_plane(&self) -> Plane

Get the left plane of the bounding box

source

pub const fn right_plane(&self) -> Plane

Get the right plane of the bounding box

source

pub const fn top(&self) -> Vector3

Get a vector of the sized normal of the top-face of the bounding box.

source

pub const fn bottom(&self) -> Vector3

Get a vector of the sized normal of the bottom-face of the bounding box.

source

pub const fn front(&self) -> Vector3

Get a vector of the sized normal of the front-face of the bounding box.

source

pub const fn back(&self) -> Vector3

Get a vector of the sized normal of the back-face of the bounding box.

source

pub const fn left(&self) -> Vector3

Get a vector of the sized normal of the left-face of the bounding box.

source

pub const fn right(&self) -> Vector3

Get a vector of the sized normal of the right-face of the bounding box.

source

pub const fn min(&self) -> &Point3

Get the minimum point of the bounding box

source

pub const fn max(&self) -> &Point3

Get the maximum point of the bounding box

source

pub fn center(&self) -> Point3

Get the center of the bounding box

source

pub fn size(&self) -> Vector3

Get the size of the bounding box

source

pub fn volume(&self) -> f32

Get the volume of the bounding box

source

pub fn planes(&self) -> [Plane; 6]

Get the planes of the bounding box.

No particular order is guaranteed, and this may change in the future.

source

pub fn vectors(&self) -> [Vector3; 6]

Get the vectors of the bounding box.

No particular order is guaranteed, and this may change in the future.

source§

impl AABB

source

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

Check if the bounding box contains a point

source§

impl AABB

source

pub fn nearest_point(&self, point: &Point3) -> Point3

Get the nearest point on the bounding box to a point

§Parameters
  • point - The point to find the nearest point to
source

pub fn distance_to(&self, point: &Point3) -> f32

Get the distance to the nearest point on the bounding box to a point

§Parameters
  • point - The point to find the nearest point to
source

pub fn square_distance_to(&self, point: &Point3) -> f32

Get the square distance to the nearest point on the bounding box to a point

§Parameters
  • point - The point to find the nearest point to

Trait Implementations§

source§

impl Encloses<Point3> for AABB

source§

fn encloses(&self, point: &Point3) -> bool

Determines if this object encloses another object. Read more
source§

impl Encloses for AABB

source§

fn encloses(&self, other: &Self) -> bool

Determines if this object encloses another object. Read more
source§

impl Intersects<AABB> for Line

source§

fn intersects(&self, other: &AABB) -> bool

Determines if this object intersects with another object. Read more
source§

impl Intersects<AABB> for Sphere

source§

fn intersects(&self, other: &AABB) -> bool

Determines if this object intersects with another object. Read more
source§

impl Intersects<Line> for AABB

source§

fn intersects(&self, other: &Line) -> bool

Determines if this object intersects with another object. Read more
source§

impl Intersects<Sphere> for AABB

source§

fn intersects(&self, other: &Sphere) -> bool

Determines if this object intersects with another object. Read more
source§

impl Intersects for AABB

source§

fn intersects(&self, other: &Self) -> bool

Determines if this object intersects with another object. Read more

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> 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, 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.