Hide

Problem D
Vacuumba

You are developing software for a new generation of robotic floor vacuums. Being an inexpensive, mass market robot, this device has a fairly simple way of navigating around the room. It can turn by some angle to the left or right and then move forward in a straight line. A plan for the robot consists of a sequence of these straight-line segments. The robot starts at the origin, facing in the positive $Y$ direction. Your job is to try to predict where the robot will be after following a plan.

\includegraphics[width=0.5\textwidth ]{path}

Input

Input consists of several test cases. The first line contains an integer $1 \leq n \leq 25$ telling how many. Each of the following test cases begins with an integer, $1 \leq m \leq 10$, giving the number of segments in the robot’s plan. This is followed by $m$ lines, each describing a segment in the plan. Each segment is described by a pair of real numbers, a rotation angle in degrees followed by a distance. The angle is in the range $[-360,360]$ and the distance is in the range $[-100,100]$. The rotation angle tells how much the robot should turn before moving forward the given distance. A positive rotation angle indicates a counter-clockwise turn. A negative angle indicates a clockwise turn. All real numbers have at most $8$ digits past the decimal.

Output

For each test case, print out the expected $X \; Y$ location of the robot after following the path. Your answer should be accurate to within $10^{-3}$ for each coordinate.

Sample Input 1 Sample Output 1
2
2
0 10.5
90 5
1
-45 10
-5.000000 10.500000
7.071068 7.071068

Please log in to submit a solution to this problem

Log in