A physics course companion to the CodePhys engine. Each section teaches a physics topic from OpenStax College Physics 2e, then shows briefly how CodePhys lets you see it and where the relevant code lives — so you can poke the physics, not just read it.
This guide is about the physics. For the engine internals (rendering, UI, the simulation
loop, the layered architecture) see docs/design/DESIGN.md. For the
primary-literature sources behind each law, method, and constant, see
docs/REFERENCES.md.
Each chapter follows the same rhythm:
- 🎯 Learning objectives — what you should be able to do afterward.
- 📖 Textbook map — the matching OpenStax chapter(s).
- 🧠 Concepts & equations — the physics, with short derivations.
- 🔬 Try it — experiments to run in the app.
- ✅ Check yourself — questions with collapsible answers.
A short "in the code" note appears where it helps connect a formula to what you can run, but the focus is the physics.
Tip
Read a section, then open the app and reproduce its claims.
cmake --preset linux-gcc && cmake --build --preset linux-gcc
./build/linux-gcc/app/codephys| # | Section | Physics | OpenStax Ch. |
|---|---|---|---|
| 01 | Vectors, Units & SI | scalars vs vectors, SI units, dimensional sense | 1, 3.2 |
| 02 | Kinematics & Projectile Motion | displacement, velocity, acceleration, parabolic flight | 2, 3 |
| 03 | Newton's Laws & Acceleration | force, mass, |
4, 5 |
| 04 | Energy, Momentum & Conservation | KE, PE, momentum, angular momentum, conservation | 7, 8, 10 |
| 05 | Simulating Motion Faithfully | why simulated energy/orbits drift, and how to keep them honest | 6–8 (applied) |
| 06 | Gravitation & Orbits | inverse-square gravity, circular orbits, Kepler | 6 |
-
Everything is SI. Metres, seconds, kilograms, radians — so a number in the sim can be compared directly to a textbook formula. → §01
-
Projectile motion is two 1D problems. Horizontal motion is constant-velocity; vertical motion is constant-acceleration under gravity. They share only a clock. → §02
-
Force sets acceleration. Newton's second law
$\mathbf{a} = \mathbf{F}/m$ is the rule the whole engine runs on: know the force, get the acceleration, advance the motion. → §03 -
Conservation laws are the truth test. With no friction, mechanical energy is conserved; with no external force, momentum is; with no torque, angular momentum is. If the sim breaks one of these when it shouldn't, something is wrong. → §04
-
A simulation only approximates the physics. How you step time decides whether energy is conserved and whether an orbit stays an orbit. Watching a planet spiral away is a physics lesson about faithfulness, not a bug. → §05
-
Gravity is inverse-square and central. That single fact gives circular-orbit speed, Kepler's third law, and conserved angular momentum. → §06
| Symbol | Meaning | SI unit |
|---|---|---|
|
|
position | m |
| velocity | m/s | |
| acceleration | m/s² | |
| mass | kg | |
| force | N (kg·m/s²) | |
| gravitational field strength | m/s² | |
dt) |
time, timestep | s |
| angle | rad (deg in UI) | |
|
|
total / kinetic / potential energy | J |
|
|
linear / angular momentum | kg·m/s, kg·m²/s |
Note
The app can only render ASCII, so on-screen you'll see T for mu for