Crate quadtree_simple

Source
Expand description

§Quadtree Simple

quadtree_simple is a library for efficiently storing and querying points in 2D space using a quadtree data structure.

§Features

  • Efficiently store and query points in 2D space
  • Supports querying by rectangle and circle
  • Easy to use with a simple API

§Examples

Here’s a simple example of how to use quadtree_simple:

use quadtree_simple::{Point, Qrect, Quadtree};

let size = 50.0;
let mut qt = Quadtree::new(Qrect::new(size, size, size, size), /* points per rect */4);

let mut qt = Quadtree::new(Qrect::corners(/*top left*/(0., 0.), /*top right*/(50., 50.)), 4);

let width = 50.; let height = 50.;
let mut qt = Quadtree::new(Qrect::screen_size(width, height), 4);

// if you don't insert anything declaration is needed
let mut qt:Quadtree<bool> = Quadtree::new(Qrect::screen_size(width, height), 4);

qt.insert(&Point::new(25., 25., false));

let found = qt.query_rect(&Qrect::range(25., 25., 1.));

For more examples, see the Examples section.

§Installation

Add this to your Cargo.toml:

[dependencies]
quadtree_simple = "0.1.0"

Then run cargo build to build your project.

§License

quadtree_simple is licensed under the MIT license. See LICENSE for more details.

Structs§

Point
A point in 2D space with that holds some data
Qrect
A rectangle anchored on center x, y with width w and height h
Quadtree
A quadtree that can store points in 2D space