Skip to content

tavurth/rust-quadtree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECIATION

No longer maintained

This crate is very old, and I was unable to bring it up to date.

The issues I'm facing now are the following:

  • impl<'a, T: Bounded> Mutable for QuadTree<'a, T>
  • impl<'a, T: Bounded> Container for QuadTree<'a, T>

I'm not sure yet how to work past this old rust code, perhaps I'll come back to it in the future.

rust-quadtree

A quadtree library for searching elements in a 2D space.

quadtree demo

Usage

extern crate quadtree;

use quadtree::{QuadTree, Bounded, Bounds};

#[deriving(Eq)]
struct Rect {
    x: f32,
    y: f32,
    width: f32,
    height: f32
}

impl Bounded for Rect {
    fn bounds(&self) -> Bounds {
        Bounds{x: self.x, y: self.y, width: self.width, height: self.height}
    }
}

fn main() {
    let mut qt = QuadTree::new(Bounds{x: 0., y: 0., width: 8., height: 8.});
    let r1 = &Rect{x: 0., y: 0., width: 2., height: 2.};
    let r2 = &Rect{x: 3., y: 3., width: 1., height: 1.};
    let r3 = &Rect{x: 1., y: 1., width: 1., height: 1.};
    qt.insert(r1);
    qt.insert(r2);
    qt.insert(r3);
    let results: Vec<&Rect> = qt.query(r3).collect();
    assert!(results.contains(&r1));
}

Installation

The basic library requires only a recent version of Rust. The demo requires rust-sfml, see that project for its dependencies.

Build targets:

make lib
make demo
make test
make doc

About

A region quadtree in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 94.2%
  • Makefile 5.8%