spatialrust_search/
traits.rs1#[derive(Clone, Copy, Debug, PartialEq)]
3pub struct Neighbor {
4 pub index: usize,
6 pub distance_squared: f32,
8}
9
10pub trait SpatialIndex {
12 fn len(&self) -> usize;
14
15 fn is_empty(&self) -> bool {
17 self.len() == 0
18 }
19}
20
21pub trait NearestNeighborIndex: SpatialIndex {
23 fn nearest_one(&self, x: f32, y: f32, z: f32) -> Option<Neighbor>;
25
26 fn nearest_k(&self, x: f32, y: f32, z: f32, k: usize) -> Vec<Neighbor>;
28}
29
30pub trait RadiusSearchIndex: SpatialIndex {
32 fn radius_search(&self, x: f32, y: f32, z: f32, radius: f32) -> Vec<Neighbor>;
34}