Created
October 7, 2017 15:58
-
-
Save djmcgill/e0a81b702d2924a0df9f0b98bc2eb3bd to your computer and use it in GitHub Desktop.
kd_tree simplification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod kd_tree { | |
use na::*; | |
use na::allocator::Allocator; | |
/// kd-Tree implementation structure | |
pub(super) enum KdTreeImpl<N> where N: DimName, DefaultAllocator: Allocator<f64, N> { | |
Node(usize, Box<KdTreeImpl<N>>, Box<VectorN<f64, N>>, Box<KdTreeImpl<N>>), | |
Empty() | |
} | |
impl<N> KdTreeImpl<N> where N: DimName, DefaultAllocator: Allocator<f64, N> { | |
/// mutably enunerate points from a kd tree into a vector - TODO: expose as iterator instead? | |
pub fn add_points_to_vector(&self, pts : &mut Vec<VectorN<f64, N>>) { | |
if let KdTreeImpl::Node(_, l, pt, r) = *self { | |
l.add_points_to_vector(pts); | |
pts.push(*pt); | |
r.add_points_to_vector(pts); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment