pub struct Aabb2<T> {
pub min: vec2<T>,
pub max: vec2<T>,
}
Expand description
2d Axis aligned bounding box.
Fields§
§min: vec2<T>
Minimum coordinates
max: vec2<T>
Maximum coordinates
Implementations§
§impl<T> Aabb2<T>where
T: Copy,
impl<T> Aabb2<T>where
T: Copy,
pub fn bottom_left(&self) -> vec2<T>
pub fn bottom_left(&self) -> vec2<T>
Get the bottom-left corner of the Aabb2.
pub fn bottom_right(&self) -> vec2<T>
pub fn bottom_right(&self) -> vec2<T>
Get the bottom-right corner of the Aabb2.
§impl<T> Aabb2<T>where
T: UNum,
impl<T> Aabb2<T>where
T: UNum,
pub fn from_corners(p1: vec2<T>, p2: vec2<T>) -> Aabb2<T>
pub fn from_corners(p1: vec2<T>, p2: vec2<T>) -> Aabb2<T>
pub fn extend_uniform(self, extend: T) -> Aabb2<T>
pub fn extend_uniform(self, extend: T) -> Aabb2<T>
pub fn extend_symmetric(self, extend: vec2<T>) -> Aabb2<T>
pub fn extend_symmetric(self, extend: vec2<T>) -> Aabb2<T>
Extend the boundaries equally right and left and equally up and down
§Examples
let aabb = Aabb2::ZERO.extend_symmetric(vec2(10, 5));
let same = Aabb2::from_corners(vec2(-10, -5), vec2(10, 5));
assert_eq!(aabb, same);
pub fn extend_positive(self, extend: vec2<T>) -> Aabb2<T>
pub fn extend_positive(self, extend: vec2<T>) -> Aabb2<T>
Extend the boundaries to the right and up by the given values
§Examples
let aabb = Aabb2::point(vec2(-10.0, -5.0)).extend_positive(vec2(20.0, 10.0));
let same = Aabb2::ZERO.extend_symmetric(vec2(10.0, 5.0));
assert_eq!(aabb, same);
pub fn extend_left(self, extend: T) -> Aabb2<T>
pub fn extend_left(self, extend: T) -> Aabb2<T>
Extend the left edge of the Aabb2 by a given value.
pub fn extend_right(self, extend: T) -> Aabb2<T>
pub fn extend_right(self, extend: T) -> Aabb2<T>
Extend the right edge of the Aabb2 by a given value.
pub fn extend_down(self, extend: T) -> Aabb2<T>
pub fn extend_down(self, extend: T) -> Aabb2<T>
Extend the bottom edge of the Aabb2 by a given value.
pub fn normalized(self) -> Aabb2<T>
pub fn normalized(self) -> Aabb2<T>
pub fn zip<U>(self, other: Aabb2<U>) -> Aabb2<(T, U)>
pub fn zip<U>(self, other: Aabb2<U>) -> Aabb2<(T, U)>
Zip every value (coordinate) with another Aabb2
pub fn map_bounds<U, F>(self, f: F) -> Aabb2<U>
pub fn map_bounds<U, F>(self, f: F) -> Aabb2<U>
Map bounds (min & max vectors)
pub fn intersects(&self, other: &Aabb2<T>) -> bool
pub fn intersects(&self, other: &Aabb2<T>) -> bool
Checks whether two Aabb2’s intersect.
pub fn points(self) -> impl Iterator<Item = vec2<T>>
pub fn points(self) -> impl Iterator<Item = vec2<T>>
Returns an iterator over points inside the Aabb2.
pub fn points_bounding_box(
points: impl IntoIterator<Item = vec2<T>>
) -> Option<Aabb2<T>>
pub fn points_bounding_box( points: impl IntoIterator<Item = vec2<T>> ) -> Option<Aabb2<T>>
Trait Implementations§
§impl<'de, T> Deserialize<'de> for Aabb2<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Aabb2<T>where
T: Deserialize<'de>,
§fn deserialize<__D>(
__deserializer: __D
) -> Result<Aabb2<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Aabb2<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl<T> FitTarget2d<T> for Aabb2<T>where
T: Float,
impl<T> FitTarget2d<T> for Aabb2<T>where
T: Float,
§fn make_fit(&self, object: &mut impl Transform2d<T>)
fn make_fit(&self, object: &mut impl Transform2d<T>)
Make given object’s bounding Quad fit into self
§impl<T> Serialize for Aabb2<T>where
T: Serialize,
impl<T> Serialize for Aabb2<T>where
T: Serialize,
§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,
Serialize this value into the given Serde serializer. Read more
impl<T> Copy for Aabb2<T>where
T: Copy,
impl<T> Eq for Aabb2<T>where
T: Eq,
impl<T> StructuralEq for Aabb2<T>
impl<T> StructuralPartialEq for Aabb2<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Aabb2<T>where
T: RefUnwindSafe,
impl<T> Send for Aabb2<T>where
T: Send,
impl<T> Sync for Aabb2<T>where
T: Sync,
impl<T> Unpin for Aabb2<T>where
T: Unpin,
impl<T> UnwindSafe for Aabb2<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
Mutably borrows from an owned value. Read more
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.