← All projectsCOSC 10 / Software

Quadtrees and collision detection

A quadtree for organizing points and finding nearby objects.

Partitioning a scene

PointQuadtree stores one point at each node and splits the remaining rectangle into four quadrants around that point. Insertion follows the matching quadrant recursively, preserving the spatial bounds at every child.

Circle queries

A proximity query first checks whether its circle intersects a node's rectangle. It only recurses into intersecting quadrants, then tests the node's point against the circle. This avoids examining every point for a local search.

Two interfaces

DotTreeGUI supports adding points and querying nearby points with the mouse. CollisionGUI puts MovingPoint instances in a quadtree on each timer update, finds overlapping circles, and can either color or remove the colliders.

CollisionGUI showing black moving points and red colliding points
Saved CollisionGUI state. Red points are collisions found through the quadtree query. View full size (new tab): CollisionGUI showing black moving points and red colliding points
Mithun RameshkumarDartmouth College