pub struct Quadtree { /* private fields */ }Expand description
The Quadtree data structure for 2D spatial searches
Implementations§
Source§impl Quadtree
impl Quadtree
Sourcepub fn new(points: &ArrayView2<'_, f64>) -> SpatialResult<Self>
pub fn new(points: &ArrayView2<'_, f64>) -> SpatialResult<Self>
Sourcepub fn query_nearest(
&self,
query: &ArrayView1<'_, f64>,
k: usize,
) -> SpatialResult<(Vec<usize>, Vec<f64>)>
pub fn query_nearest( &self, query: &ArrayView1<'_, f64>, k: usize, ) -> SpatialResult<(Vec<usize>, Vec<f64>)>
Query the k nearest neighbors to a given point
§Arguments
query- The query pointk- The number of nearest neighbors to find
§Returns
A tuple of (indices, distances) where:
- indices: Indices of the k nearest points in the original data
- distances: Squared distances to those points
§Errors
Returns an error if the query point doesn’t have 2 dimensions or if k is 0
Sourcepub fn query_radius(
&self,
query: &ArrayView1<'_, f64>,
radius: f64,
) -> SpatialResult<(Vec<usize>, Vec<f64>)>
pub fn query_radius( &self, query: &ArrayView1<'_, f64>, radius: f64, ) -> SpatialResult<(Vec<usize>, Vec<f64>)>
Query all points within a given radius of a point
§Arguments
query- The query pointradius- The search radius
§Returns
A tuple of (indices, distances) where:
- indices: Indices of the points within the radius in the original data
- distances: Squared distances to those points
§Errors
Returns an error if the query point doesn’t have 2 dimensions or if radius is negative
Sourcepub fn points_in_region(&self, region: &BoundingBox2D) -> bool
pub fn points_in_region(&self, region: &BoundingBox2D) -> bool
Sourcepub fn get_points_in_region(&self, region: &BoundingBox2D) -> Vec<usize>
pub fn get_points_in_region(&self, region: &BoundingBox2D) -> Vec<usize>
Sourcepub fn bounds(&self) -> Option<BoundingBox2D>
pub fn bounds(&self) -> Option<BoundingBox2D>
Get the bounding box of the quadtree
§Returns
The bounding box of the entire quadtree, or None if the tree is empty
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Quadtree
impl RefUnwindSafe for Quadtree
impl Send for Quadtree
impl Sync for Quadtree
impl Unpin for Quadtree
impl UnwindSafe for Quadtree
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.