The Quadtree data structure used in QuadtreeAlgorithm. More...
#include <quadtree.h>
Public Member Functions | |
Quadtree (int levelIn, double nwXIn, double nwYIn, double seXIn, double seYIn) | |
Constructs a Quadtree object. More... | |
void | clear () |
Clears the Quadtree. More... | |
void | split () |
Splits the Quadtree into 4 quadrants. More... | |
int | getIndex (Particle *particle) |
Gets the index of a given Particle within a Quadtree. More... | |
void | insertToTree (Particle *particle) |
Inserts a given Particle into a Quadtree. More... | |
std::vector< Particle * > * | getPossibleColliders (std::vector< Particle * > *colliders, Particle *p) |
Returns a vector of Particles that may be colliding with a given Particle. More... | |
The Quadtree data structure used in QuadtreeAlgorithm.
A Quadtree represents a rectangular section of space defined in the X,Y coordinate system.
Quadtree::Quadtree | ( | int | levelIn, |
double | nwXIn, | ||
double | nwYIn, | ||
double | seXIn, | ||
double | seYIn | ||
) |
Constructs a Quadtree object.
Constructs a Quadtree object based on the given parameters.
levelIn | the level of the Quadtree object within the larger tree. The head of the tree is 0 and increases from there. |
nwXIn | the X coordinate of the upper left corner of the space represented by this level of the tree. |
nwYIn | the Y coordinate of the upper left corner of the space represented by this level of the tree. |
seXIn | the X coordinate of the bottom right corner of the space represented by this level of the tree. |
seYIn | the Y coordinate of the bottom right corner of the space represented by this level of the tree. |
void Quadtree::clear | ( | ) |
int Quadtree::getIndex | ( | Particle * | particle | ) |
Gets the index of a given Particle within a Quadtree.
Gets the index of a given Particle within a Quadtree. An index of -1 means the Particle cannot fit completely within any of the 4 nodes. An index of 0, 1, 2, or 3 means the Particle fits completely within the cooresponding node.
particle | pointer to the Particle to get an index of. |
std::vector< Particle * > * Quadtree::getPossibleColliders | ( | std::vector< Particle * > * | colliders, |
Particle * | p | ||
) |
Returns a vector of Particles that may be colliding with a given Particle.
Returns a pointer to a vector of pointers to Particles that may be colliding with a given Particle.
colliders | pointer to the vector of Particles that may be colliding with a given Particle. |
p | pointer to the given Particle to check against. |
void Quadtree::insertToTree | ( | Particle * | particle | ) |
void Quadtree::split | ( | ) |