THE COLLISION DETECTION

Do these two shapes touch — and what happens when they do. A live engine tests overlap three ways (axis-aligned bounding box, sphere–sphere, and the Separating Axis Theorem for convex polygons), then resolves the hit with an elastic response that conserves both momentum and kinetic energy. Rendered, not quoted.

SOURCE Gilbert, Johnson & Keerthi (1988), “A Fast Procedure for Computing the Distance Between Complex Objects in Three-Dimensional Space,” IEEE J. Robotics & Automation 4(2):199–203 · DOI 10.1109/56.2083 — paywalled; id AMBER-verified via IEEE Xplore doc 2083.

Blue Team · builds & defends
3

The Model

A convex shape is the intersection of half-planes. Two convex shapes do not touch iff there exists a line onto which their shadows (projections) do not overlap — a separating axis.

For polygons it suffices to test the edge normals of both shapes. Overlap holds iff every tested axis shows overlapping intervals: no separating axis exists.

overlap(A,B) = ¬∃ axis : proj(A) ∥ proj(B) disjoint
  = axis : intervals overlap
5

The Lineage

Two questions, one seam. Do these two things touch? — detection, the separating-axis theorem. And when they do: a momentum-and-energy-conserving bounce — the physics of contact.

Neighbour sphere: the-contact-response in KRÂSIS (52) — detection here hands the contact normal to the response there.

7

The Witness

Live re-check: the SAT verdict is compared, on constructed pairs, against an independent brute-force overlap oracle. Green iff they agree on every pair.

witness idle

Press TAMPER (window 6) and this flips red within one frame — the planted void cannot hide from the oracle.

The Machine
4

Data In IN ↓

Two convex polygons in the plane, each a list of vertices. Below: a fixed diamond A and a moving square B, plus their velocities and masses for the response.

A: diamond, centre (0,0)
B: square, sliding along −x → +x
mA = mB = 1   e = 1 (elastic)
0

The Panel LIT booting…

SAT verdict:
Sep. axis:
Total KE:
Total p:

Detection is real satOverlap(); the bounce is the real elastic impulse along the contact normal. KE and momentum are printed live and stay flat — the collision is exact, not damped.

8

Data Out OUT ↓

Proven at boot by selfcheck() (throws on any violation, runs with no canvas):

SAT ≡ brute-force overlap  
AABB = overlap on all axes  
equal-mass head-on → velocities swap  
Σp and ΣKE conserved to 1e−9  
contact normal ̂ unit, impulse exact  
Red Team · attacks & breaks
1

The Adversary WALL

Bounding boxes lie. Two diamonds whose AABBs overlap can still be cleanly apart — the gap lives on a diagonal axis no box edge tests. A broad-phase AABB pass is a filter, never a verdict.

SAT is exact only for convex shapes. A concave polygon can be non-overlapping on every edge normal yet still intersect — it must be decomposed into convex pieces first, or SAT reports a false miss.

2

The Graveyard

“Their boxes overlap, so they collide.”
→ AABB overlap is necessary, not sufficient. Confirm with SAT / GJK.

“Overlap on some axis means a hit.”
→ Backwards. A hit needs overlap on every axis; overlap on one proves nothing.

“An elastic bounce can lose a little energy.”
→ Then it is not elastic (e<1). Elastic means ΣKE is invariant, exactly.

6

The Tamper

The disclosed planted void: flip satOverlap to report a hit when the shapes overlap on any single axis (instead of requiring no separating axis). Two disjoint shapes are then falsely called colliding.

The Witness (window 7) catches it: the SAT-vs-brute check diverges on the disjoint pair.