mirror of
https://github.com/andreytkachenko/kdtree-rust.git
synced 2024-11-21 17:06:24 +04:00
Added distance_squared_to_nearest
This commit is contained in:
parent
e6755865f0
commit
2b4539f331
@ -71,7 +71,11 @@ impl<KdtreePoint: KdtreePointTrait> Kdtree<KdtreePoint> {
|
||||
pub fn has_neighbor_in_range(&self, node: &KdtreePoint, range: f64) -> bool {
|
||||
let squared_range = range * range;
|
||||
|
||||
squared_euclidean(&self.nearest_search(node).dims(), node.dims()) <= squared_range
|
||||
self.distance_squared_to_nearest(node) <= squared_range
|
||||
}
|
||||
|
||||
pub fn distance_squared_to_nearest(&self, node: &KdtreePoint) -> f64 {
|
||||
squared_euclidean(&self.nearest_search(node).dims(), node.dims())
|
||||
}
|
||||
|
||||
pub fn insert_node(&mut self, node_to_add : KdtreePoint) {
|
||||
|
@ -10,7 +10,7 @@ fn gen_random() -> f64 {
|
||||
rand::thread_rng().gen_range(0., 10000.)
|
||||
}
|
||||
|
||||
fn find_nn_with_linear_search<'a>(points : &'a Vec<Point3WithId>, find_for : Point3WithId) -> &Point3WithId {
|
||||
fn find_nn_with_linear_search(points : &Vec<Point3WithId>, find_for : Point3WithId) -> &Point3WithId {
|
||||
let distance_fun = kdtree::kdtree::distance::squared_euclidean;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user