A terminal-based projectile simulator built with Ratatui. Run multiple force-model scenarios side by side and compare their trajectories and energy curves — all inside your terminal.
- 4 launch parameters — angle, speed, mass, initial height
- 5 force-model scenarios — toggle each one on or off independently
- Vacuum (gravity only)
- Linear drag — Stokes law
F = −b·v - Quadratic drag — realistic air resistance
F = −½ρCdA|v|v - Quadratic drag + headwind
- Moon gravity (g = 1.62 m/s²)
- RK4 numerical integrator — 4th-order Runge-Kutta, far more accurate than Euler
- ASCII trajectory chart — all enabled scenarios overlaid in one view
- Results table — range, max height, flight time, energy change per scenario
- Energy chart — E/E₀ vs normalised flight time; flat = conserved, dropping = dissipated
cargo run --releaseFor a debug build:
cargo run| Key | Action |
|---|---|
↑ / ↓ / Tab / Shift+Tab |
Move between fields and scenarios |
Enter on a parameter field |
Edit the value |
Enter / Space on a scenario |
Toggle it on or off |
Enter on Run button |
Run all enabled scenarios |
r |
Run immediately from anywhere |
PgUp / PgDn |
Scroll the results panel |
q |
Quit |
While editing a value:
| Key | Action |
|---|---|
Enter |
Confirm and run |
Esc |
Cancel edit |
← / → / Home / End |
Move cursor |
Backspace / Delete |
Delete character |
The equations of motion are:
dr/dt = v(t)
dv/dt = F_net(r, v, t) / m
Solved at each time step with a 4th-order Runge-Kutta scheme (local error O(h⁵)):
k1 = f(t, y )
k2 = f(t + h/2, y + h/2·k1)
k3 = f(t + h/2, y + h/2·k2)
k4 = f(t + h, y + h·k3 )
y(t+h) = y(t) + h/6 · (k1 + 2k2 + 2k3 + k4)
Force models:
| Scenario | Force law |
|---|---|
| Vacuum | F = m·g downward |
| Linear drag | F_drag = −b·v |
| Quadratic drag | F_drag = −½ρCdA·|v|·v (baseball params) |
| Drag + headwind | Quadratic drag + F_wind = k·(v_wind − v) |
| Moon gravity | F = m·1.62 downward |
