Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artemeff/quadtree
Simple QuadTree implementation in pure C99
https://github.com/artemeff/quadtree
Last synced: 12 days ago
JSON representation
Simple QuadTree implementation in pure C99
- Host: GitHub
- URL: https://github.com/artemeff/quadtree
- Owner: artemeff
- License: mit
- Created: 2013-11-12T13:13:19.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-28T09:35:35.000Z (almost 11 years ago)
- Last Synced: 2024-11-05T12:12:45.138Z (about 2 months ago)
- Language: C
- Homepage:
- Size: 226 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### quadtree
---
### Installation
```bash
$ git clone && cd
$ make
$ make install
```---
### Usage
```c
#include
#includeint main() {
int val = 10;
quadtree_t *tree = quadtree_new(0, 0, 10, 10);
quadtree_insert(tree, 1, 1, 1, &val);
quadtree_insert(tree, 2, 2, 2, &val);
quadtree_insert(tree, 3, 3, 3, &val);printf("tree length: %d\n", tree->length);
return 0;
}
```Finds in tree:
```c
result_node_t *head, *cur;void within_callback(point_t *point) {
printf("%d\n", point->x);
}quadtree_within(tree->root, bbox, within_callback);
```Walks in tree:
```c
void ascent(node_t *node) {
if (node && node->point) {
printf("%d\n", node->point->x);
}
}void descent(node_t *node) {
if (node && node->point) {
printf("%d\n", node->point->x);
}
}quadtree_walk(tree->root, &ascent, &descent);
```Reference:
```c
// Create new tree and return pointer
quadtree_t *
quadtree_new(double minx, double miny, double maxx, double maxy)// Insert point to the tree and return point pointer
point_t *
quadtree_insert(quadtree_t *tree, double x, double y, void *key, bool update)// Search if tree has point and return point pointer
point_t *
quadtree_search(quadtree_t *tree, double x, double y)// Destroy tree
void
quadtree_free(quadtree_t *tree)// Walks in tree, works like each for points
void
quadtree_walk(node_t *root, void (*descent)(node_t *node),
void (*ascent)(node_t *node))// Find points in bbox
void
quadtree_within(node_t *root, bounds_t *bounds, within_callback_t cb)
```---
### Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Make changes
4. `make test benchmark`
5. Commit your changes (`git commit -am 'add some feature'`)
6. Push to the branch (`git push origin my-new-feature`)
7. Create new Pull Request