Implemented a QuadTree and a test
This commit is contained in:
parent
a569dd05a6
commit
87f592ea8b
4 changed files with 519 additions and 1 deletions
25
tests/QuadTree.test.c
Normal file
25
tests/QuadTree.test.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
#include "../src/rand/xoshiro256.h"
|
||||
#include <stdio.h>
|
||||
#include "../src/QuadTree/QuadTree.h"
|
||||
|
||||
static QuadTree tree;
|
||||
|
||||
typedef struct Particle_s {
|
||||
QuadTreeLeaf position;
|
||||
} Particle;
|
||||
|
||||
static Particle particles[100];
|
||||
|
||||
int main()
|
||||
{
|
||||
QuadTree_Create(&tree, 10000, 10000, NULL);
|
||||
|
||||
Xoshiro256State rand_state = { 0, 10, 0, 0 };
|
||||
|
||||
for (size_t i = 0; i < sizeof(particles) / sizeof(particles[0]); i++) {
|
||||
particles[i].position.x = xoshiro256_next(&rand_state) % 10000;
|
||||
particles[i].position.y = xoshiro256_next(&rand_state) % 10000;
|
||||
printf("%f %f\n", particles[i].position.y, particles[i].position.x);
|
||||
QuadTree_Insert(&tree, &particles[i].position);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue