Libraries for physics simulation on javascript canvas
JavaScript Other
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

jsphys: javascript physics simulation

Provides canvas-based JavaScript physics demonstrations for classroom use, including a live special relativity simulator.


jsphys encapsulates a growing library of simulations and explanations of physical phenomena, from wave interference to special relativity.

Relativity simulation

jsphys provies a framework for relativistic demos, using predefined scenarios to demonstrate relativistic effects. Users can interact with the demos, changing their reference frames, zooming in and out, and changing the playback speed. Currently supported effects are:

  • Relativistic Doppler shifting
  • Length contraction of distances and of objects
  • Time dilation
  • Arbitrarily shaped objects
  • Minkowski diagrams of events as they unfold.

Planned effects include relativistic beaming and arbirary object paths. The simulator will also support audio narration, allowing users to step through demonstrations as they listen to explanations of what they're seeing.


Send a pull request! The user interface could stand serious improvement, and our GitHub issue queue lists features and bugs that need to be worked on.


jsphys uses features like canvas and JavaScript typed arrays, requiring a recent browser. It has currently been tested on recent versions of Firefox, Chrome, Safari, and Internet Explorer.


A demo of the work-in-progress version of jsphys is available: