Cannonball Trajectory


Anyone who has observed a baseball in motion (or, for that matter any other object thrown into the air) has observed projectile motion.  The ball moves in a curved path and its motion is simple to analyze if two assumptions are made: the free fall acceleration is constant over the range of motion and is directed downward, and the effect of air resistance is negligible.  With these assumptions made, it was found that the path of a projectile or its trajectory is always a parabola. 


When calculating the path of a projectile, it is important to keep track of the height of the projectile.  Back during the civil war there were no computers to do this for the army, and when a cannonball was launched, the angle of elevation was simply estimated.  Your job is to help the army by constructing a graph of a cannonball during its flight, when given the angle of elevation and the velocity at which it will travel.


The path that a projectile takes once it has been launched can be modeled with the following equations (given by Sir Issac Newton):


X=V * T * COS(A)
Y=(V * T * SIN(A))-(0.5 * G * (T2))



X = horizontal distance the projectile has traveled
Y = height of the projectile
A = the angle of degrees above the horizon
G = acceleration due to gravity (9.8 meters/s2 on earth)
T = the number of seconds into the flight we are interested in
V = velocity of the projectile


Using the above equations, for any given T, we can compute how high (Y) the projectile will be and how far down range (X) the projectile will be.


The cannon has 4 notches of elevation:

   Notch 1: 30 degrees

   Notch 2: 45 degrees

   Notch 3: 60 degrees

   Notch 4: 70 degrees


Your program will input 2 numbers, the notch number and velocity and then print a horizontal bar graph that plots the cannonball's height every time X increases by 50 meters. For example, it might look like this:



  50 ****

100 *********

150 ************

200 *****************

250 *********************

300 *****************

350 ************

400 *********

450 ****


Where each star represents 10 meters of height (Y). Since Y will not always come out an even multiple of 10, you should round up to the next even multiple of 10 (15 would be 2 stars). You should continue to plot until the height becomes negative which means that the cannonball has hit the ground. If Y does not become negative when X has reached 1000 meters, then you should stop plotting anyway.

In order to plot the path you will need to use the built in SIN and COS functions. These functions expect an angle measured in radians instead of degrees. This means that you must convert the degrees to radians before you call SIN or COS (180 degrees = pi radians, 90 degrees = pi/2 radians, etc).

For our purposes, we will use pi = 3.14159.




The input file will contain a list of numbers, one on each line.  The first number corresponds to the notch of the cannon, and the second number corresponds to the velocity.  Input should be read until the notch and velocity are both zero, indicating the end of input.




X distances should be right justified, so that 50 lines up with 1000.  There should be one space between the distance and the first star.  There should be a blank line between each set of output.  There should not be a blank line at the end of the output.