Documentation

OpenPhysics is a free, open-source interactive physics platform. This page covers setup, architecture, and how to extend the project.

Getting Started

git clone <repo>
cd OpenPhysics
npm install
npm run dev

Open http://localhost:3000. Production build: npm run build && npm start.

Features

  • 16 simulations across mechanics, waves, optics, E&M, modern physics, thermo
  • Topic notes with YouTube lessons and draw-on-notes canvas
  • Whiteboard — pen, shapes, text, multi-tab sync, PNG export
  • Tools — calculator, unit converter, constants
  • Physics engine: RK4, Verlet, Euler, springs, gravity, drag, Coulomb
  • PWA manifest for installable / offline-friendly use

Architecture

  • Next.js 15 App Router + React 19 + TypeScript
  • Tailwind CSS with semantic + brand tokens
  • /physics — engine (Vector2, Particle, integrators, forces, World)
  • /simulations — interactive canvases
  • /components — UI, notes, whiteboard
  • /app/topics — curriculum notes per module

Using the Physics Engine

import { World, Particle, Vector2, UniformGravity } from "@/physics";

const world = new World({ integrator: "rk4", fixedDt: 1/120 });
const p = new Particle({
  mass: 1,
  position: new Vector2(0, 10),
  velocity: new Vector2(5, 0),
});
world.addParticle(p);
world.addForce(new UniformGravity(new Vector2(0, -9.81)));

// in rAF loop:
world.step(dt);

Whiteboard Collaboration

The whiteboard uses the BroadcastChannel API to sync strokes across tabs on the same origin. Data is stored in localStorage only — nothing is sent to a server. For cross-device collaboration you would add a WebSocket backend; the stroke model is ready for that.

License

MIT. Free for learning, teaching, and research.