https://github.com/keyan/kdtree
Spatial index for nearest neighbor queries over K-dimensional points
https://github.com/keyan/kdtree
data-structures geospatial
Last synced: 8 months ago
JSON representation
Spatial index for nearest neighbor queries over K-dimensional points
- Host: GitHub
- URL: https://github.com/keyan/kdtree
- Owner: keyan
- License: mit
- Created: 2018-11-17T22:54:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-18T00:49:10.000Z (over 7 years ago)
- Last Synced: 2025-02-09T00:42:42.273Z (about 1 year ago)
- Topics: data-structures, geospatial
- Language: C++
- Homepage:
- Size: 96.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kdtree
C++11 single header file k-d tree implementation, supports dynamic insertion and nearest neighbor queries.
Implementation based on lecture notes from Dr. David Mount:
http://www.cs.umd.edu/users/mount/420/Lects/420lects.pdf
## Usage
- Copy `kdtree.h` to your project and include during compilation
- Only supports `insert()` and `nearest()` operations
- Example usage:
```
#include "kdtree.h"
// Specify dimension count K
KDTree tree = KDTree(3);
// Insert points as std::vector with length K
std::vector p = {1, 2, 3};
tree.insert(p);
// Query for nearest point
std::vector s = {5, 6, 7};
std::vector nearby_point = tree.nearest(s);
```