pub struct Quadtree2D { /* private fields */ }Expand description
Adaptive 2D quadtree supporting dynamic insert/remove/update, rect, radius, and k-NN queries.
Implementations§
Source§impl Quadtree2D
Dynamic insertion, update, removal, and spatial queries for Quadtree2D.
impl Quadtree2D
Dynamic insertion, update, removal, and spatial queries for Quadtree2D.
Sourcepub fn new(root_bounds: Bounds2D, config: QuadtreeConfig) -> Self
pub fn new(root_bounds: Bounds2D, config: QuadtreeConfig) -> Self
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the total number of indexed items currently stored in this quadtree.
§Returns
usize- Number of stored items.
Sourcepub fn query_rect(&self, query_bounds: Bounds2D, out: &mut Vec<u64>)
pub fn query_rect(&self, query_bounds: Bounds2D, out: &mut Vec<u64>)
Queries all items whose positions lie inside query_bounds, writing IDs into out.
§Arguments
Bounds2D- Axis-aligned query rectangle.&mut Vec<u64>- Reusable output identifier buffer (cleared first).
Sourcepub fn query_radius(&self, center: Vec2, radius: f32, out: &mut Vec<u64>)
pub fn query_radius(&self, center: Vec2, radius: f32, out: &mut Vec<u64>)
Queries all items within Euclidean distance <= radius of center, writing IDs into out.
§Arguments
Vec2- Query circle center.f32- Query radius (non-negative).&mut Vec<u64>- Reusable output identifier buffer (cleared first).
Sourcepub fn query_k_nearest(
&mut self,
center: Vec2,
k: usize,
out: &mut Vec<(u64, f32)>,
)
pub fn query_k_nearest( &mut self, center: Vec2, k: usize, out: &mut Vec<(u64, f32)>, )
Finds the exact k nearest items to center using best-first branch-and-bound traversal.
§Arguments
Vec2- Query center point.usize- Maximum number of nearest neighbors to return.&mut Vec<(u64, f32)>- Reusable output receiving(id, euclidean_distance)sorted ascending.
Source§impl Quadtree2D
Implements impl #impl_generics #name #ty_generics #where_clause.
impl Quadtree2D
Implements impl #impl_generics #name #ty_generics #where_clause.
pub fn get_root_bounds(&self) -> Bounds2D
pub fn get_mut_root_bounds(&mut self) -> &mut Bounds2D
pub fn set_root_bounds(&mut self, val: Bounds2D) -> &mut Self
pub fn get_config(&self) -> QuadtreeConfig
pub fn get_mut_config(&mut self) -> &mut QuadtreeConfig
pub fn set_config(&mut self, val: QuadtreeConfig) -> &mut Self
Trait Implementations§
Source§impl Clone for Quadtree2D
impl Clone for Quadtree2D
Auto Trait Implementations§
impl Forget for Quadtree2D
impl Freeze for Quadtree2Dwhere
*const u8 is !null: Freeze,
PhantomData<QuadtreeNode2D>: Freeze,
PhantomData<(u64, Vec2)>: Freeze,
PhantomData<(f32, usize)>: Freeze,
PhantomData<(f32, u64)>: Freeze,
impl Move for Quadtree2D
impl RefUnwindSafe for Quadtree2D
impl Send for Quadtree2D
impl Sync for Quadtree2D
impl Unpin for Quadtree2D
impl UnsafeUnpin for Quadtree2Dwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<QuadtreeNode2D>: UnsafeUnpin,
PhantomData<(u64, Vec2)>: UnsafeUnpin,
PhantomData<(f32, usize)>: UnsafeUnpin,
PhantomData<(f32, u64)>: UnsafeUnpin,
impl UnwindSafe for Quadtree2D
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