pub struct AABB<T> {
pub x_min: T,
pub x_max: T,
pub y_min: T,
pub y_max: T,
}
Expand description
Axis aligned bounding box.
Fields§
§x_min: T
§x_max: T
§y_min: T
§y_max: T
Implementations§
Source§impl<T> AABB<T>where
T: UNum,
impl<T> AABB<T>where
T: UNum,
pub fn bottom_left(&self) -> Vec2<T>
pub fn bottom_right(&self) -> Vec2<T>
pub fn top_left(&self) -> Vec2<T>
pub fn top_right(&self) -> Vec2<T>
pub fn center(&self) -> Vec2<T>
pub fn from_corners(p1: Vec2<T>, p2: Vec2<T>) -> AABB<T>
pub fn pos_size(pos: Vec2<T>, size: Vec2<T>) -> AABB<T>
pub fn map<U, F>(self, f: F) -> AABB<U>
pub fn width(&self) -> T
Sourcepub fn contains(&self, point: Vec2<T>) -> bool
pub fn contains(&self, point: Vec2<T>) -> bool
Check if a point is inside the rect.
§Examples
use batbox::*;
let rect = AABB::from_corners(vec2(1, 2), vec2(3, 4));
assert!(rect.contains(vec2(2, 3)));
assert!(!rect.contains(vec2(5, 5)));
pub fn intersects(&self, other: &AABB<T>) -> bool
pub fn translate(self, v: Vec2<T>) -> AABB<T>
pub fn add_padding(self, padding: T) -> AABB<T>
pub fn points(&self) -> impl Iterator<Item = Vec2<T>>
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>,
Deserialize this value from the given Serde deserializer. Read more
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,
Serialize this value into the given Serde serializer. Read more
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> 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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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 more