Skip to main content

SpatialIndex

Trait SpatialIndex 

Source
pub trait SpatialIndex<T: Clone> {
    // Required methods
    fn insert(&mut self, pos: Vec3, item: T);
    fn query_radius(&self, center: Vec3, radius: f32) -> Vec<(T, Vec3, f32)>;
    fn k_nearest(&self, center: Vec3, k: usize) -> Vec<(T, Vec3, f32)>;
    fn clear(&mut self);
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Common interface for spatial acceleration structures.

Required Methods§

Source

fn insert(&mut self, pos: Vec3, item: T)

Insert an item at the given position.

Source

fn query_radius(&self, center: Vec3, radius: f32) -> Vec<(T, Vec3, f32)>

Query all items within radius of center.

Source

fn k_nearest(&self, center: Vec3, k: usize) -> Vec<(T, Vec3, f32)>

Query the k nearest items to center.

Source

fn clear(&mut self)

Remove all items.

Source

fn len(&self) -> usize

Total number of stored items.

Provided Methods§

Source

fn is_empty(&self) -> bool

Implementors§