A simple implementation of an Euler integrator for projectile motion. This program was written (mostly) live, in lecture for SOFE-2850U in Fall 2017.
Next week, we will add drag and stopping conditions. The drag will make the output more interesting. Implementing stopping conditions in a generic way force us to introduce lambdas and templates.
Compile with
clang++ -std=c++14 -o projectile projectile.cpp
or
g++ -std=c++14 -o projectile projectile.cpp
and run as
./projectile
and watch your terminal fill with numbers.
The output will be six columns of numbers with the following order:
time [s], x-position [m], y-position [m], x-speed [m/s], y-speed [m/s]
Plot the, you get the familiar parabolic trajectory, which will depend on your constants: