Struct static_aabb2d_index::AABB[][src]

pub struct AABB<T = f64> {
    pub min_x: T,
    pub min_y: T,
    pub max_x: T,
    pub max_y: T,
}

Simple 2D axis aligned bounding box which holds the extents of a 2D box.

Fields

min_x: T

Min x extent of the axis aligned bounding box.

min_y: T

Min y extent of the axis aligned bounding box.

max_x: T

Max x extent of the axis aligned bounding box.

max_y: T

Max y extent of the axis aligned bounding box.

Implementations

impl<T> AABB<T> where
    T: IndexableNum
[src]

pub fn new(min_x: T, min_y: T, max_x: T, max_y: T) -> AABB<T>[src]

pub fn overlaps_aabb(&self, other: &AABB<T>) -> bool[src]

Tests if this AABB overlaps another AABB (inclusive).

Examples

use static_aabb2d_index::AABB;
let box_a = AABB::new(0, 0, 2, 2);
let box_b = AABB::new(1, 1, 3, 3);
assert!(box_a.overlaps_aabb(&box_b));
assert!(box_b.overlaps_aabb(&box_a));

let box_c = AABB::new(-1, -1, 0, 0);
assert!(!box_c.overlaps_aabb(&box_b));
// note: overlap check is inclusive of edges/corners touching
assert!(box_c.overlaps_aabb(&box_a));

pub fn overlaps(&self, min_x: T, min_y: T, max_x: T, max_y: T) -> bool[src]

Tests if this AABB overlaps another AABB. Same as AABB::overlaps_aabb but accepts AABB extent parameters directly.

pub fn contains_aabb(&self, other: &AABB<T>) -> bool[src]

Tests if this AABB fully contains another AABB (inclusive).

Examples

use static_aabb2d_index::AABB;
let box_a = AABB::new(0, 0, 3, 3);
let box_b = AABB::new(1, 1, 2, 2);
assert!(box_a.contains_aabb(&box_b));
assert!(!box_b.contains_aabb(&box_a));

pub fn contains(&self, min_x: T, min_y: T, max_x: T, max_y: T) -> bool[src]

Tests if this AABB fully contains another AABB. Same as AABB::contains but accepts AABB extent parameters directly.

Trait Implementations

impl<T: Clone> Clone for AABB<T>[src]

impl<T: Copy> Copy for AABB<T>[src]

impl<T: Debug> Debug for AABB<T>[src]

impl<T> Default for AABB<T> where
    T: IndexableNum
[src]

impl<T: Eq> Eq for AABB<T>[src]

impl<T: Hash> Hash for AABB<T>[src]

impl<T: PartialEq> PartialEq<AABB<T>> for AABB<T>[src]

impl<T> StructuralEq for AABB<T>[src]

impl<T> StructuralPartialEq for AABB<T>[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.