Tiny.js is a 2D physics library I wrote in JavaScript to explore collision detection. It uses the separating axis theorem, usually shortened to SAT.
A geometric idea you can see
SAT looks for an axis on which the projections of two convex polygons do not overlap. Finding that separation lets us rule out a collision.
The demo turns the idea into a scene with moving objects. Watch how the bodies behave, then follow the implementation in the source code.
Explore the project
Start with collision detection and follow the data through the simulation. Changing a shape or its position is a useful way to see what each step calculates.