Simulate the trajectory of a projectile while accounting for air resistence.
Find a file
2023-10-10 10:04:52 +03:00
.github Bump actions/setup-python from 3 to 4 2023-10-07 20:55:32 +00:00
projectile simulation: have print_range method also return the projectile range 2023-10-08 00:01:32 +03:00
.envrc direnv 2023-10-07 23:54:43 +03:00
.gitignore Initial commit 2023-10-07 22:56:23 +03:00
default.nix nix toolkit 2023-10-07 23:53:53 +03:00
flake.lock nix toolkit 2023-10-07 23:53:53 +03:00
flake.nix clean up nix tooling 2023-10-10 10:04:52 +03:00
LICENSE add a license 2023-10-07 22:57:13 +03:00
main.py make params customizable 2023-10-07 22:57:32 +03:00
README.md add tests section 2023-10-08 00:01:04 +03:00
requirements.txt make params customizable 2023-10-07 22:57:32 +03:00
setup.py add a setup.py for nix 2023-10-07 23:53:38 +03:00
shell.nix clean up nix tooling 2023-10-10 10:04:52 +03:00
test_main.py testing framework 2023-10-07 23:13:21 +03:00

Projectile Simulation

This project simulates the motion of a projectile with air resistance.

Installation

  1. Clone this repository.
  2. Install the required packages using pip:
pip install -r requirements.txt

Usage

Run the main.py script:

python main.py

Or alternatively, with your own parameters:

python main.py --g 9.8 --C_d 0.02 --v_init 150 --theta 45 --h_init 20 --dt 0.01 --t_end 10

Arguments

  • --g: The acceleration due to gravity in m/s^2. Default is 9.81.
  • --C_d: The drag coefficient. Default is 0.01.
  • --v_init: The initial velocity in m/s. Default is 100.
  • --theta: The launch angle in degrees. Default is 180.
  • --h_init: The launch height in meters. Default is 10.
  • --dt: The time step in seconds. Default is 0.01.
  • --t_end: The total time of the simulation in seconds. Default is 10.

Testing

Tests can be invoked by simply running pytest in the directory. If you are contributing something new to the program, do make sure that it is appropriately tested in test_main.py.