Struct ark_api::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 = Self{ min: Vec3::ZERO, max: Vec3::ZERO,}

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 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 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<'de> Deserialize<'de> for BoundingBox

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<BoundingBox, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<BoundingBox> for BoundingBox

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a_, C_> Readable<'a_, C_> for BoundingBoxwhere C_: Context,

source§

fn read_from<R_>( _reader_: &mut R_ ) -> Result<BoundingBox, <C_ as Context>::Error>where R_: Reader<'a_, C_>,

source§

fn minimum_bytes_needed() -> usize

source§

fn read_from_buffer_with_ctx( context: C, buffer: &'a [u8] ) -> Result<Self, <C as Context>::Error>

source§

fn read_with_length_from_buffer_with_ctx( context: C, buffer: &'a [u8] ) -> (Result<Self, <C as Context>::Error>, usize)

source§

fn read_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8] ) -> Result<Self, <C as Context>::Error>

source§

fn read_with_length_from_buffer_copying_data_with_ctx( context: C, buffer: &[u8] ) -> (Result<Self, <C as Context>::Error>, usize)

source§

fn read_with_length_from_buffer_copying_data_with_ctx_mut( context: &mut C, buffer: &[u8] ) -> (Result<Self, <C as Context>::Error>, usize)

source§

fn read_from_stream_unbuffered_with_ctx<S>( context: C, stream: S ) -> Result<Self, <C as Context>::Error>where S: Read,

source§

fn read_from_stream_buffered_with_ctx<S>( context: C, stream: S ) -> Result<Self, <C as Context>::Error>where S: Read,

source§

fn read_from_file_with_ctx( context: C, path: impl AsRef<Path> ) -> Result<Self, <C as Context>::Error>

source§

impl Serialize for BoundingBox

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<C_> Writable<C_> for BoundingBoxwhere C_: Context,

source§

fn write_to<T_>(&self, _writer_: &mut T_) -> Result<(), <C_ as Context>::Error>where T_: Writer<C_> + ?Sized,

source§

fn write_to_buffer_with_ctx( &self, context: C, buffer: &mut [u8] ) -> Result<(), <C as Context>::Error>

source§

fn write_to_buffer_with_ctx_mut( &self, context: &mut C, buffer: &mut [u8] ) -> Result<(), <C as Context>::Error>

source§

fn write_to_vec_with_ctx( &self, context: C ) -> Result<Vec<u8, Global>, <C as Context>::Error>

source§

fn write_to_vec_with_ctx_mut( &self, context: &mut C ) -> Result<Vec<u8, Global>, <C as Context>::Error>

source§

fn write_to_stream_with_ctx<S>( &self, context: C, stream: S ) -> Result<(), <C as Context>::Error>where S: Write,

source§

fn write_to_file_with_ctx( &self, context: C, path: impl AsRef<Path> ) -> Result<(), <C as Context>::Error>

source§

fn bytes_needed(&self) -> Result<usize, <C as Context>::Error>

source§

impl Copy for BoundingBox

source§

impl StructuralPartialEq for BoundingBox

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,