Struct ark_api::BoundingBox
source · [−]Expand description
A 3-dimensional axis-aligned bounding box
Fields
min: Vec3
Bounding box minimum (inclusive).
max: Vec3
Bounding box maximum (inclusive).
Implementations
sourceimpl BoundingBox
impl BoundingBox
sourcepub const ZERO: BoundingBox = Self{ min: Vec3::ZERO, max: Vec3::ZERO,}
pub const ZERO: BoundingBox = Self{ min: Vec3::ZERO, max: Vec3::ZERO,}
A BoundingBox
that only contains Vec3::ZERO
.
sourcepub fn nothing() -> BoundingBox
pub fn nothing() -> BoundingBox
A BoundingBox
that contains no points.
This is useful as the seed for bounding bounding boxes.
sourcepub fn everything() -> BoundingBox
pub fn everything() -> BoundingBox
A BoundingBox
that contains every point.
sourcepub fn from_min_max(min: Vec3, max: Vec3) -> BoundingBox
pub fn from_min_max(min: Vec3, max: Vec3) -> BoundingBox
Create a bounding box from a minimum and maximum position.
pub fn from_min_size(min: Vec3, size: Vec3) -> BoundingBox
sourcepub fn from_center_size(center: Vec3, size: Vec3) -> BoundingBox
pub fn from_center_size(center: Vec3, size: Vec3) -> BoundingBox
Create a bounding box from a center position and a size.
sourcepub fn from_points(points: impl Iterator<Item = Vec3>) -> BoundingBox
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.
sourcepub fn is_something(&self) -> bool
pub fn is_something(&self) -> bool
sourcepub fn is_nothing(&self) -> bool
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()
.
sourcepub fn is_finite(&self) -> bool
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
.
sourcepub fn bounding_sphere_radius(&self) -> f32
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.
pub fn union(self, other: BoundingBox) -> BoundingBox
sourcepub fn intersection(self, other: BoundingBox) -> BoundingBox
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.
sourcepub fn contains(&self, point: Vec3) -> bool
pub fn contains(&self, point: Vec3) -> bool
Returns true
if the point is within (or on the edge of) the box.
sourcepub fn expanded(&self, padding: Vec3) -> BoundingBox
pub fn expanded(&self, padding: Vec3) -> BoundingBox
Expand with this much padding on each side.
sourcepub fn translated(&self, translation: Vec3) -> BoundingBox
pub fn translated(&self, translation: Vec3) -> BoundingBox
Translate (move) the box by this much.
sourcepub fn rotated_around_origin(&self, q: &Quat) -> BoundingBox
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.
sourcepub fn transform_iso(&self, m: &IsoTransform) -> BoundingBox
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.
sourcepub fn transform_affine3(&self, m: &Affine3A) -> BoundingBox
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.
Trait Implementations
sourceimpl Clone for BoundingBox
impl Clone for BoundingBox
sourcefn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BoundingBox
impl Debug for BoundingBox
sourceimpl Default for BoundingBox
impl Default for BoundingBox
sourcefn default() -> BoundingBox
fn default() -> BoundingBox
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for BoundingBox
impl<'de> Deserialize<'de> for BoundingBox
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<BoundingBox, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
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
sourceimpl PartialEq<BoundingBox> for BoundingBox
impl PartialEq<BoundingBox> for BoundingBox
sourcefn eq(&self, other: &BoundingBox) -> bool
fn eq(&self, other: &BoundingBox) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<'a_, C_> Readable<'a_, C_> for BoundingBox where
C_: Context,
impl<'a_, C_> Readable<'a_, C_> for BoundingBox where
C_: Context,
fn read_from<R_>(
_reader_: &mut R_
) -> Result<BoundingBox, <C_ as Context>::Error> where
R_: Reader<'a_, C_>,
fn minimum_bytes_needed() -> usize
fn read_from_buffer_with_ctx(
context: C,
buffer: &'a [u8]
) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_with_ctx(
context: C,
buffer: &'a [u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_buffer_copying_data_with_ctx(
context: C,
buffer: &[u8]
) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_copying_data_with_ctx(
context: C,
buffer: &[u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_with_length_from_buffer_copying_data_with_ctx_mut(
context: &mut C,
buffer: &[u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_stream_unbuffered_with_ctx<S>(
context: C,
stream: S
) -> Result<Self, <C as Context>::Error> where
S: Read,
fn read_from_stream_buffered_with_ctx<S>(
context: C,
stream: S
) -> Result<Self, <C as Context>::Error> where
S: Read,
fn read_from_file_with_ctx(
context: C,
path: impl AsRef<Path>
) -> Result<Self, <C as Context>::Error>
sourceimpl Serialize for BoundingBox
impl Serialize for BoundingBox
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
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
sourceimpl<C_> Writable<C_> for BoundingBox where
C_: Context,
impl<C_> Writable<C_> for BoundingBox where
C_: Context,
fn write_to<T_>(&self, _writer_: &mut T_) -> Result<(), <C_ as Context>::Error> where
T_: Writer<C_> + ?Sized,
fn write_to_buffer_with_ctx(
&self,
context: C,
buffer: &mut [u8]
) -> Result<(), <C as Context>::Error>
fn write_to_buffer_with_ctx_mut(
&self,
context: &mut C,
buffer: &mut [u8]
) -> Result<(), <C as Context>::Error>
fn write_to_vec_with_ctx(
&self,
context: C
) -> Result<Vec<u8, Global>, <C as Context>::Error>
fn write_to_vec_with_ctx_mut(
&self,
context: &mut C
) -> Result<Vec<u8, Global>, <C as Context>::Error>
fn write_to_stream_with_ctx<S>(
&self,
context: C,
stream: S
) -> Result<(), <C as Context>::Error> where
S: Write,
fn write_to_file_with_ctx(
&self,
context: C,
path: impl AsRef<Path>
) -> Result<(), <C as Context>::Error>
fn bytes_needed(&self) -> Result<usize, <C as Context>::Error>
impl Copy for BoundingBox
impl StructuralPartialEq for BoundingBox
Auto Trait Implementations
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnwindSafe for BoundingBox
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more