Skip to content

amirabbas-gh/projectile-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Projectile Sim

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.

Projectile Sim terminal interface

Features

  • 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

Build & Run

cargo run --release

For a debug build:

cargo run

Key Bindings

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

Physics

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

About

Terminal-based projectile simulation — compare force models with ASCII charts

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages