4 releases

0.1.7 May 16, 2024
0.1.6 May 16, 2024

#3 in #quad-tree

Download history 423/week @ 2024-05-16 8/week @ 2024-05-23 6/week @ 2024-05-30

437 downloads per month

MIT license

8MB
364 lines

Contains (rust library, 575KB) libautocfg-1cdb70c4e96086a8.rlib, (DOS exe, 325KB) build-script-build.exe, (DOS exe, 325KB) build_script_build-da9b2ee92cdc3b4f.exe, (DOS exe, 270KB) build-script-build.exe, (DOS exe, 270KB) build_script_build-c010ef51dd302dd2.exe, (DOS exe, 350KB) build-script-build.exe and 19 more.

Quadtree Library

This is a Rust library for implementing a Quadtree data structure, which is useful for efficiently storing and querying spatial data in two dimensions.

Features

  • Store points with associated data in a 2D space
  • Query points within a rectangular region or circular area
  • Subdivision of space based on a configurable capacity
  • Efficient insertion and query operations

Usage

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

// Create a new quadtree with a bounding rectangle and capacity
// rects are (w, y, w, h) with x and y being anchored in the center
let size = 50.0;
let mut qt = Quadtree::new(Qrect::new(size, size, size, size), 4);

// Insert points with associated data
qt.insert(&Point::new(25., 25., 0));
qt.insert(&Point::new(30., 20., 1));

// Query points within a rectangular region
let rect = Qrect::new(20., 20., 10., 10.);
let points_in_rect = qt.query_rect(&rect);

// Query points within a circular area
let circle_points = qt.query_circle(25., 25., 5.);

No runtime deps