[][src]Struct fart_aabb::AabbTree

pub struct AabbTree<T, U, V> { /* fields omitted */ }

A tree mapping from axis-aligned bounding boxes to T values.

Methods

impl<T, U, V> AabbTree<T, U, V> where
    T: Copy + Num + PartialOrd
[src]

pub fn new() -> AabbTree<T, U, V>[src]

Construct a new, empty AABB tree.

pub fn insert(&mut self, aabb: Aabb<T, U>, value: V)[src]

Insert the given value into the AABB tree.

Important traits for IterOverlapping<'a, T, U, V>
pub fn iter_overlapping(&self, aabb: Aabb<T, U>) -> IterOverlapping<T, U, V>[src]

Iterate over each of the AABB keys and associated values that overlap with the given AABB.

Order of iteration is not defined.

use euclid::Point2D;
use fart_aabb::{AabbTree, Aabb};

let mut tree = AabbTree::new();
tree.insert(Aabb::new(Point2D::new(0.0, 0.0), Point2D::new(2.0, 2.0)), "Alice");
tree.insert(Aabb::new(Point2D::new(2.0, 2.0), Point2D::new(4.0, 4.0)), "Bob");
tree.insert(Aabb::new(Point2D::new(10.0, 10.0), Point2D::new(20.0, 20.0)), "Zed");

let target = Aabb::new(Point2D::new(1.0, 1.0), Point2D::new(3.0, 3.0));
for (aabb, who) in tree.iter_overlapping(target) {
    match *who {
        "Alice" => println!("Found Alice at {:?}", aabb),
        "Bob" => println!("Found Bob at {:?}", aabb),
        someone => panic!("Found someone we shouldn't have: {}", someone),
    }
}

pub fn any_overlap(&self, aabb: Aabb<T, U>) -> bool[src]

Do any of the AABBs in this tree overlap with the give AABB?

Trait Implementations

impl<T: Debug, U: Debug, V: Debug> Debug for AabbTree<T, U, V>[src]

Auto Trait Implementations

impl<T, U, V> Send for AabbTree<T, U, V> where
    T: Send,
    U: Send,
    V: Send

impl<T, U, V> Sync for AabbTree<T, U, V> where
    T: Sync,
    U: Sync,
    V: Sync

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.