pub struct KdTree { /* private fields */ }Expand description
A KD-tree for efficient nearest neighbor queries in 3D.
Implementations§
Source§impl KdTree
impl KdTree
Sourcepub fn build(cloud: &PointCloud) -> Self
pub fn build(cloud: &PointCloud) -> Self
Build a KD-tree from a point cloud.
Sourcepub fn from_positions(positions: &[[f64; 3]]) -> Self
pub fn from_positions(positions: &[[f64; 3]]) -> Self
Build from raw positions.
Sourcepub fn nearest(&self, query: [f64; 3]) -> Option<(usize, f64)>
pub fn nearest(&self, query: [f64; 3]) -> Option<(usize, f64)>
Find the nearest neighbor to a query point.
Returns (index, squared_distance).
Sourcepub fn k_nearest(&self, query: [f64; 3], k: usize) -> Vec<(usize, f64)>
pub fn k_nearest(&self, query: [f64; 3], k: usize) -> Vec<(usize, f64)>
Find k nearest neighbors.
Returns a vector of (index, squared_distance) sorted by distance.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KdTree
impl RefUnwindSafe for KdTree
impl Send for KdTree
impl Sync for KdTree
impl Unpin for KdTree
impl UnsafeUnpin for KdTree
impl UnwindSafe for KdTree
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<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.