P
R
O
G
R
A
M
M
I
N
G
 
C
O
M
P
E
T
I
T
I
O
N
 

Particle Trajectory

Task #6
Novice/Advanced
6 Points

Task Description
A trajectory is a curve that describes the motion of an object, such as the orbit of a comet or the flight path of a rocket.
 
   
Figure 1
Closer to the earth, an object that is thrust into the air, like a golf ball or artillery shell, also follows a curved motion from launch to impact. Figure 1 is an example trajectory graph showing height and distance travelled.
     Your program will read the initial speed and launch angle from a file and then compute the flight time of an object along its trajectory, and also compute both the maximum vertical height and the horizontal distance travelled. For contest purposes we assume that (1) the only external force applied during the object's flight is gravity, and (2) the ground is completely flat.

Program Input
The first line of the input file specifies the number of trajectories described in the file. Each line thereafter is a separate trajectory descriptor. Each trajectory is described by two values: (1) the initial speed in meters per second, and (2) the launch angle in degrees.

2
44.8 30.0
72.1 56.9

Program Output
The program must write the three computed values to the output file using the text prompts shown in the example output below. Each trajectory should produce four lines of output in the order shown. You must include unit measures (like meters and seconds). For contest purposes you may ignore round-off error.

trajectory 1
horizontal distance: 177 meters
flight time: 4.57 seconds
maximum height: 25.6 meters
trajectory 2
horizontal distance: 485 meters
flight time: 12.3 seconds
maximum height: 186 meters


Hint
 
   
Figure 2
To solve this problem you'll need to know some specific math and physics. Since this is a programming contest and not a physics contest, we'll provide most of the basic information you should need to solve the problem.
     To compute the horizontal (or X axis) and vertical (or Y axis) components of the initial velocity use the formulas below. See Figure 2 for the corresponding vector diagram.

Vx0 = V0 cosq          Vy0 = V0 sinq
     You should also use the formula for linear distance d=Żat▓+v0t, linear velocity v=at+v0, and the gravitational acceleration constant a=-9.8m/s▓. The variables in these formulas are: a=acceleration, v=velocity*, t=time, d=distance.

One way to solve this task is to break it down into sub tasks like this:
1. Compute the time required to acheive maximum height by solving the linear velocity equation where vy=ayt+vy0=0
2. Multiply the result of Step 1 by two to determine the total flight time.
3. Use the result of Step 1 in the linear distance formula to compute the maximum vertical height.
4. Use the result of Step 2 in the linear distance formula to compute the horizontal distance travelled.


* To be precise we are using the variable v as speed and not velocity per se. Vector math is beyond the scope of this task presentation.