Space Comps
 All Classes Files Functions Variables
quadtree.h
1 #ifndef QUADTREE_H
2 #define QUADTREE_H
3 #include "boundingbox.h"
4 
10 class Quadtree
11 {
12 public:
24  Quadtree(int levelIn,
25  double nwXIn, double nwYIn,
26  double seXIn, double seYIn);
27  ~Quadtree();
28 
34  void clear();
35 
41  void split();
42 
50  int getIndex(Particle* particle);
51 
58  void insertToTree(Particle* particle);
59 
68  std::vector<Particle*>* getPossibleColliders(std::vector<Particle *> *colliders, Particle* p);
69 
70 
71 private:
72  int maxParticles;
73  int maxLevels;
74  int level;
75  std::vector<Particle*> nodeParticles;
76  double nwX;
77  double nwY;
78  double seX;
79  double seY;
80  Quadtree* nodes [4];
81 
82 };
83 
84 #endif // QUADTREE_H
int getIndex(Particle *particle)
Gets the index of a given Particle within a Quadtree.
Definition: quadtree.cpp:55
void clear()
Clears the Quadtree.
Definition: quadtree.cpp:32
std::vector< Particle * > * getPossibleColliders(std::vector< Particle * > *colliders, Particle *p)
Returns a vector of Particles that may be colliding with a given Particle.
Definition: quadtree.cpp:131
The Quadtree data structure used in QuadtreeAlgorithm.
Definition: quadtree.h:10
void split()
Splits the Quadtree into 4 quadrants.
Definition: quadtree.cpp:44
Definition: particle.h:12
Quadtree(int levelIn, double nwXIn, double nwYIn, double seXIn, double seYIn)
Constructs a Quadtree object.
Definition: quadtree.cpp:4
void insertToTree(Particle *particle)
Inserts a given Particle into a Quadtree.
Definition: quadtree.cpp:91