Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QuadTree motivation

This repo implements a QuadTree (more correctly, an orthtree) in Rust. It is generic over the number of dimensions, the type of data stored, and the shape of the region being queried. Any struct that implements `Storable` can be inserted. When querying, pass in any region that implements `Query`.
This repo implements a QuadTree (more correctly, an orthtree) in Rust. It is generic over the number of dimensions, the type of data stored, and the shape of the region being queried. Any struct that is `Storable` can be inserted. When querying, pass in any region that is `Query`. `Point` is automatically `Storable`

# Usage

Expand All @@ -19,7 +19,7 @@ let region = Region::new(&[
// it implements the Storable trait.
// Here we're deferring the type of the QuadTree to the compiler,
// inferred from the first insert
let mut quadtree = QuadTree::new(&region, NonZero::new(4).unwrap());
let mut quadtree = QuadTree::new(&region, NonZero::new(4).expect("4 is non-zero"));

// Insert points into the QuadTree
for i in 0..4 {
Expand All @@ -41,4 +41,4 @@ assert_eq!(results.len(), 2);

To run the `nannou` app, run `cargo run --bin visualize`.

![](assets/vis.gif)
![](assets/vis.gif)
10 changes: 5 additions & 5 deletions quadtree/src/quadtree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ pub trait Storable<V, const N: usize> {
/// ]);
///
/// // Initialise the QuadTree with this region and the maximum number of points each individual node
/// // should store. You can store any Struct in the QuadTree as long as it implements the Storable trait.
/// // should store.
/// // Here we're deferring the type of the QuadTree to the compiler,
/// // inferred from the first insert
/// let mut quadtree = QuadTree::new(&region, NonZero::new(4).ok_or_eyre("value must be > 0")?);
/// // inferred from the first insert of a [Storable] item.
/// let mut quadtree = QuadTree::new(&region, NonZero::new(4).expect("4 is non-zero"));
///
/// // Insert points into the QuadTree
/// // Insert points into the QuadTree. You can insert any type that is [Storable].
Comment thread
alexespencer marked this conversation as resolved.
/// for i in 0..4 {
/// quadtree.insert(Point::new(&[i, 0]))?;
/// }
///
/// // To query the QuadTree, provide a region, or anything that implements the Query trait
/// // To query the QuadTree, provide a region, or anything that is [Query]
Comment thread
alexespencer marked this conversation as resolved.
/// let query_region = Region::new(&[
/// Interval::try_new(0.0, 2.0)?,
/// Interval::try_new(0.0, 10.0)?,
Expand Down