Skip to content

Collision Detection

Overview

Collision detection answers "are these two things touching?" This covers the three cheap tests that cover most 2D games (AABB, circle-circle, circle-AABB), the more general SAT test for rotated shapes, and spatial partitioning for when you have too many objects to check naively.

Core Algorithms (Pseudocode)

AABB vs AABB (Axis-Aligned Bounding Box) Circle vs Circle

Circle vs AABB Separating Axis Theorem (SAT) - convex polygons Spatial Partitioning (uniform grid)

The Math

AABB vs AABB (Axis-Aligned Bounding Box)

Circle vs Circle

Circle vs AABB

Separating Axis Theorem (SAT) - convex polygons

Spatial Partitioning (uniform grid)