Robot Crash |
The DoD company has contractod to determine under what conditions a pair of scanner robots can collide. The robots are fired simultaneously from ``guns" that are mounted near opposite ends of a horizontal strip. They travel in straight lines until they hit a wall of the strip or until they are in the same spot at the approximately the same time.
Whenever a robot hits a wall, it bounces off without loss of speed and in a straight line so that the angle of incidence equals the angle of reflection.
If the robots are in the same spot at approximately the same time, then they ``collide."
Write a program to determine whether robots collide and if so where. To simplify the computer model of the physical problem, assume the following.
Input for your program is a text file which contains data for several different pairs of robots. The lines of the text file come in pairs. The first line of a pair gives initial firing information about the robot fired from the leftmost gun. The second line of the pair gives initial firing information about the robot fired from the rightmost gun. Each line contains 4 data items as follows:
x-coordinate y-coordinate angle speed
(all values are real numbers, angle is in degrees)
The end of input is indicated by end-of-file. Assume that the input is error-free.
To help maintain floating point accuracy when converting degrees to radians, use the predeclared constant pi.
For each robot problem, output from your program should consist of the number of the problem (ex: Robot problem #1, Robot problem #2), colon and a statement indicating whether or not the robots do collide. If they do collide, your prograrn should also print the coordinates of the point of collision. If the robots collide multiple times, write the coordinates of collision point with shortest passing interval. If there're many of such points, write the one with lowest x coordinate. All real output should be printed with 2 digits to the right of the decimal.
0 4 0 3.3 40 5 125 5 1 6 -5 10 5 2 95 20 2 5 45 5 42 5 -135 5 0 6 20 3 0 5 180 4
Robot Problem #1: Robots do not collide. Robot Problem #2: Robots collide at (4.68,5.68). Robot Problem #3: Robots collide at (22.00,5.00). Robot Problem #4: Robots do not collide.