Skip to the content of the web site.

Project U.3: Projectile motion

Given a projectile that is fired with an initial speed of $v_0$ at an angle of $\theta$ radians, it is possible to predict both the maximum height and range of the projectile assuming no air friction.

$h = \frac{v_0^2 \sin^2(\theta)}{2g}$
$r = \frac{v_0^2 \sin(2\theta)}{g}$

where $g$ is acceleration due to gravity. Given an initial speed and angle, you should write two functions that calculate these two values. The function declarations should be:

double projectile_maximum_height( double initial_speed, double angle );
double projectile_range( double initial_speed, double angle );

and your documentation should clearly specify the units of the parameters and the units of the return values.

Now, write a function that, given the initial speed of the projectile and a desired range, have that function return an appropriate angle at which to launch the projectile.

double projectile_angle( double initial_speed, double desired_range );

Throw a std::domain_error exception if the range is beyond the maximum range of the projectile.

Your documentation should specify whether you are returning the smaller or larger angle, as with the exception of the maximum range (45°), there are two angles that will reach the same point.

or m