We have seen in many mythological movies, the arrows shot, by the opponents collide midair and one devour the other.
You wanted to simulate a similar situation for the video game you are designing. In the game, the opponents are in a tunnel and have a gun each. They can shoot bullets in any direction (within limits). The roof and floor of the tunnel are perfect surfaces and any object hitting them are bounced off according to the law of reflection (angle of incidence equals the angle of reflection), with unchanged speed. For simplicity, we can assume that the tunnel is a two dimensional horizontal strip. Of course, this being the mythological world, gravity does not exist, and the bullets travel in straight lines at constant spped until being reflected (or they collide).
The two guns are positioned at half the height (h) of the tunnel, at a distance D apart.
The two guns fire simultaneously. The trajectories of the bullets (if extended) will meet at a maximum of one point. They are said to collide if their trajectories meet, and the two bullets arrive at that point within 0.5 seconds of each other.
The shooting angle varies from -85 degrees to 85 degrees from the horizontal. For the left gun, the angles are measured anti-clockwise, and for the right gun they are measured clockwise. Hence, with a positive angle for both, the left gun shoots up and to the right, and the right gun shoots up and to the left.
Write a program to decide whether the bullets shot will collide or not. If they do, determine where will they collide. The coordinate axes for reference have origin at the midpoint of the line joining the guns, X axis along the line joining the guns. Hence, the left gun’s coordinates are (-D/2,0) and the right gun’s coordinates are (D/2,0). The equations for the top of the tunnel is y=h/2, and of the bottom of the tunnel is y=-h/2.
The input has two lines.
The first line has two comma separated positive integers, h and D (the height of the tunnel and the distance between them). The unit of distance measurement is myth units.
The second line has four comma separated numbers (with up to two decimals each) giving LA, LS, RA and RS respectively, where LA, LS denote the angle (in degrees) and speed of firing (in myth units per second) of the left gun and RA, RS denote the angle (in degrees) and speed of firing (in myth units per second) of the right gun.
If the two collide (the trajectories meet, and they arrive at the meeting point within 0.5 seconds of each other), the output is a comma separated string of the word Yes and the coordinates of the colliding point.
Yes, x, y
Here, x and y are the coordinates of the collision point, and each must be rounded to two decimal places If they do not collide, the output is the word No.