pub struct Aabb<T> {
pub min: Vec3<T>,
pub max: Vec3<T>,
}Expand description
Axis-aligned Bounding Box (3D), represented by min and max points.
N.B: You are responsible for ensuring that all respective elements of
min are indeed less than or equal to those of max.
The is_valid(), make_valid() and made_valid() methods are designed to help you
with this.
Fields§
§min: Vec3<T>Minimum coordinates of bounds.
max: Vec3<T>Maximum coordinates of bounds.
Implementations§
Source§impl<T> Aabb<T>
impl<T> Aabb<T>
Sourcepub fn is_valid(&self) -> boolwhere
T: PartialOrd,
pub fn is_valid(&self) -> boolwhere
T: PartialOrd,
Is this bounding shape valid ?
True only if all elements of self.min are less than or equal to those of self.max.
Sourcepub fn make_valid(&mut self)where
T: PartialOrd,
pub fn make_valid(&mut self)where
T: PartialOrd,
Makes this bounding shape valid by swapping elements of self.min with self.max as needed.
Sourcepub fn made_valid(self) -> Aabb<T>where
T: PartialOrd,
pub fn made_valid(self) -> Aabb<T>where
T: PartialOrd,
Returns this bounding shape made valid by swapping elements of self.min with self.max as needed.
Sourcepub fn new_empty(p: Vec3<T>) -> Aabb<T>where
T: Copy,
pub fn new_empty(p: Vec3<T>) -> Aabb<T>where
T: Copy,
Creates a new bounding shape from a single point.
Sourcepub fn into_rect3(self) -> Rect3<T, T>
pub fn into_rect3(self) -> Rect3<T, T>
Converts this bounding shape to the matching rectangle representation.
Sourcepub fn union(self, other: Aabb<T>) -> Aabb<T>where
T: PartialOrd,
pub fn union(self, other: Aabb<T>) -> Aabb<T>where
T: PartialOrd,
Gets the smallest bounding shape that contains both this one and another.
Sourcepub fn intersection(self, other: Aabb<T>) -> Aabb<T>where
T: PartialOrd,
pub fn intersection(self, other: Aabb<T>) -> Aabb<T>where
T: PartialOrd,
Gets the largest bounding shape contained by both this one and another.
Sourcepub fn expand_to_contain(&mut self, other: Aabb<T>)where
T: Copy + PartialOrd,
pub fn expand_to_contain(&mut self, other: Aabb<T>)where
T: Copy + PartialOrd,
Sets this bounding shape to the union of itself with another.
Sourcepub fn intersect(&mut self, other: Aabb<T>)where
T: Copy + PartialOrd,
pub fn intersect(&mut self, other: Aabb<T>)where
T: Copy + PartialOrd,
Sets this bounding shape to the intersection of itself with another.
Sourcepub fn expanded_to_contain_point(self, p: Vec3<T>) -> Aabb<T>where
T: Copy + PartialOrd,
pub fn expanded_to_contain_point(self, p: Vec3<T>) -> Aabb<T>where
T: Copy + PartialOrd,
Gets a copy of this shape so that it contains the given point.
Sourcepub fn expand_to_contain_point(&mut self, p: Vec3<T>)where
T: Copy + PartialOrd,
pub fn expand_to_contain_point(&mut self, p: Vec3<T>)where
T: Copy + PartialOrd,
Expands this shape so that it contains the given point.
Sourcepub fn contains_point(self, p: Vec3<T>) -> boolwhere
T: PartialOrd,
pub fn contains_point(self, p: Vec3<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape contain the given point ?
Sourcepub fn contains_aabb(self, other: Aabb<T>) -> boolwhere
T: PartialOrd,
pub fn contains_aabb(self, other: Aabb<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape fully contain another ?
Sourcepub fn collides_with_aabb(self, other: Aabb<T>) -> boolwhere
T: PartialOrd,
pub fn collides_with_aabb(self, other: Aabb<T>) -> boolwhere
T: PartialOrd,
Does this bounding shape collide with another ?
Sourcepub fn collision_vector_with_aabb(self, other: Aabb<T>) -> Vec3<T>
pub fn collision_vector_with_aabb(self, other: Aabb<T>) -> Vec3<T>
Gets a vector that tells how much self penetrates other.
Sourcepub fn projected_point(self, p: Vec3<T>) -> Vec3<T>where
T: Clamp,
pub fn projected_point(self, p: Vec3<T>) -> Vec3<T>where
T: Clamp,
Project the given point into the bounding shape (equivalent to ‘snapping’ the point to the closest point in the bounding shape).
Sourcepub fn distance_to_point(self, p: Vec3<T>) -> T
pub fn distance_to_point(self, p: Vec3<T>) -> T
Get the smallest distance between the bounding shape and a point.
Sourcepub fn split_at_x(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
pub fn split_at_x(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
Splits this shape in two, by a straight plane along the
x
axis.
The returned tuple is (low, high).
§Panics
sp is assumed to be a position along the
x
axis that is within this shape’s bounds.
Sourcepub fn split_at_y(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
pub fn split_at_y(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
Splits this shape in two, by a straight plane along the
y
axis.
The returned tuple is (low, high).
§Panics
sp is assumed to be a position along the
y
axis that is within this shape’s bounds.
Sourcepub fn split_at_z(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
pub fn split_at_z(self, sp: T) -> [Aabb<T>; 2]where
T: Copy + PartialOrd,
Splits this shape in two, by a straight plane along the
z
axis.
The returned tuple is (low, high).
§Panics
sp is assumed to be a position along the
z
axis that is within this shape’s bounds.
Sourcepub fn map<D, F>(self, f: F) -> Aabb<D>where
F: FnMut(T) -> D,
pub fn map<D, F>(self, f: F) -> Aabb<D>where
F: FnMut(T) -> D,
Returns this bounding shape, converted element-wise using the given closure.
Sourcepub fn as_<D>(self) -> Aabb<D>where
T: AsPrimitive<D>,
D: 'static + Copy,
pub fn as_<D>(self) -> Aabb<D>where
T: AsPrimitive<D>,
D: 'static + Copy,
Converts this rectangle to a rectangle of another type, using the as conversion.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Aabb<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Aabb<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Aabb<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Aabb<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<T> Serialize for Aabb<T>where
T: Serialize,
impl<T> Serialize for Aabb<T>where
T: Serialize,
Source§fn 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,
impl<T> Copy for Aabb<T>where
T: Copy,
impl<T> Eq for Aabb<T>where
T: Eq,
impl<T> StructuralPartialEq for Aabb<T>
Auto Trait Implementations§
impl<T> Freeze for Aabb<T>where
T: Freeze,
impl<T> RefUnwindSafe for Aabb<T>where
T: RefUnwindSafe,
impl<T> Send for Aabb<T>where
T: Send,
impl<T> Sync for Aabb<T>where
T: Sync,
impl<T> Unpin for Aabb<T>where
T: Unpin,
impl<T> UnsafeUnpin for Aabb<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Aabb<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.