Research : Spatial : Brute Force Collision Detection

For a general description of the problem, please see Collision Detection. This is a brute force, broad-phase collision detection algorithm. Assume that every object has a bounding radius.

local collisions = {}
for _, object_1 in pairs(objects) do
  for _, object_2 in pairs(objects) do
    if object_1 == object_2 then 
      next -- we can't collide with ourself
    end

    if distance(object_1, object_2) < object_1.radius + object_2.radius then
      table.insert(collisions, {object_1, object_2})
    end
  end
end

Notes & References