Collision lab

The collision and physics code from cptclvtch’s engine, running in your browser. He built a visual debugger like this to watch two shapes meet; this is that idea, carried over. Drag any view to turn it.

Two shapes

Move and turn shape B into shape A. When they touch, the lime dot is where they meet, the arrow is the direction they would push apart, and the number is how far they overlap.

Many shapes

Checking every shape against every other gets slow fast. His engine sorts shapes into a tree of boxes, each holding the boxes below it, so only nearby shapes get compared. Shapes in a near pair turn blue; actual touches turn lime.

Springs and particles

His particle physics: gravity pulls down at 10 meters per second squared, and every step keeps 99% of the speed. The chain is points joined by his springs, hung from a point that never moves. The burst uses his explosion preset and his own random number formula, so it bursts the same way every time.

Particles fall forever; his engine has no floor yet, so they’re cleared after a few seconds.

What’s his and what was finished

Most of this is his code carried over as written, and it passes his own tests. Some parts were still marked unfinished in his code, or had small bugs. Those were finished or fixed here, following the physics book he was working through.

His, as writtenVector math and rotors (his geometric algebra), box overlap checks, sphere against sphere, sphere against box, box against box when a corner hits a face, the box tree’s insert rule, particle motion, springs, the explosion preset and its random numbers.
FinishedBox against box when two edges cross (marked TODO in his code). The bounding box of a turned box (marked FIXME).
FixedSphere against box only checked one side of the box. A sphere whose centre was inside a box had no direction to push. Box size along a tilted axis was measured from one corner instead of all three edges. The tree skipped some pairs when two branches didn’t touch.
Not carried over yetRigid bodies bouncing and spinning off each other. That part of his engine was still mostly notes to himself.