Extending Geom.Rectangle to Box2D-Lite

I came across a tutorial version of the famous Box2D physics engine written in C++ back in 2006. As it is a tutorial code, it is (relatively) short but has features well beyond the typical freely available tutorial. I set about porting it to JS/Phaser by extending the Geom.Rectangle class.
Please don’t say “just use Matter.js!” This is simply for fun and education!
image

Extending Geom.Rectangle to Box2D-Lite, Warm Starting (codepen.io)
(After completing my port, I found that Richard Davey himself has already ported the same into TypeScript - however his version is a “souped up” version with a quad-tree added for extra measure)

I have structured my code in Javascript as very close to the original so it should be easy to follow with the associated documentation. Also, as I developed my port in stages, I jotted down my learnings, so for anyone wanting to learn about physics engines, I hope some will find below interesting.

  1. Basic Box2D-Lite classes
  2. Separating Axis Theorem
  3. Clipping Contact Points
  4. Sequential Impulse
  5. Friction
  6. Revolute Joint
  7. Warm Starting