Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Projectile Motion Simulator

An interactive, animated simulator comparing projectile motion under three different drag models:

  • No drag — closed-form parabolic trajectory
  • Linear drag — drag force proportional to velocity (closed-form solution)
  • Quadratic drag — drag force proportional to velocity squared (solved numerically with scipy.integrate.solve_ivp)

All three trajectories are animated together against real elapsed time, so you can see which one lands first, along with live height-vs-time and speed-vs-time plots and a results table (range, max height, time of flight).

Output

Projectile motion simulator demo

All three drag models launched at the same speed and angle (u=20 m/s, θ=45°), animated together in real time. No drag flies farthest and lands last; quadratic drag falls behind first.

Features

  • Live animated trajectory, height, and speed plots, synced to a shared clock
  • Editable initial conditions: launch speed (u), launch angle (θ), linear-drag time constant (τ), and quadratic-drag coefficient (k)
  • Play/Pause control, with the animation holding briefly at the end of each flight before looping
  • Dark theme UI
  • Optional Numba JIT-acceleration for the quadratic-drag ODE, with automatic fallback to plain Python if Numba isn't installed

Requirements

  • Python 3.9+
  • See requirements.txt

Setup

pip install -r requirements.txt

Usage

python projectile.py

Type new values for u, θ, τ, and k into the text boxes and click Run to recompute and replay the animation. Click Pause/Play to freeze or resume it at any point.

Physics

With initial conditions:

$$ x(0) = 0, \quad y(0) = 0, \quad v_{x}(0) = u\cos(\theta), \quad v_{y}(0) = u\sin(\theta) $$

No drag (closed form):

$$ x(t) = v_{x0},t $$

$$ y(t) = v_{y0},t - \frac{1}{2}g,t^{2} $$

Linear drag (drag force $= -\dfrac{m}{\tau}v$, closed form):

$$ x(t) = u\cos(\theta),\tau\left(1 - e^{-t/\tau}\right) $$

$$ y(t) = \tau\big(u\sin(\theta) + g\tau\big)\left(1 - e^{-t/\tau}\right) - g,\tau,t $$

Quadratic drag (numerical):

$$ x'' = -k,v,x' $$

$$ y'' = -g - k,v,y', \quad \text{where } v = \sqrt{(x')^{2} + (y')^{2}} $$

License

MIT — see LICENSE.

About

Interactive projectile motion simulator with three physics models (no drag, linear drag, quadratic drag), live synced animation, adjustable launch conditions, and a dark-themed UI — Python, NumPy, SciPy, Matplotlib, Numba.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages