## GPS

### Instructions

In this activity, you must write a program in RISC-V assembly language that computes your geographical coordinates in a bidimensional plane, based on the current time and messages received from 3 satellites.

To simplify the exercise, it is assumed that satellite A is placed at the origin of the cartesian plane (0, 0), while B and C are positioned at (0, Y_{B}) and (X_{C}, 0), respectively. The satellites continuously send messages with a timestamp, which marks when the message was sent, via waves that propagate in all directions at a speed of 3 x 10^{8} m/s. At a given time T_{R}, you receive a message from each satellite containing the timestamps T_{A}, T_{B}, and T_{C}. Assuming that all clocks are perfectly synchronized, print your coordinates (x, y) in the cartesian plane. Note that the formulation used in this exercise is not realistic.

### Input

**Line 1**- Coordinates Y_{B}and X_{c}. Values are in meters, represented by 4-digit integers in decimal base and preceded by a sign ('+' or '-').**Line 2**- Times T_{A}, T_{B}, T_{c}and T_{R}. Values are in nanoseconds, represented by 4-digit integers in decimal base

### Output

**Your coordinate**- (x, y). Values are in meters, approximated, represented by 4-digit integers in decimal base and preceded by a sign ('+' or '-').

### Examples

Test Case | Input | Output |
---|---|---|

1 | +0700 -0100 2000 0000 2240 2300 | -0088 +0016 |

2 | +1042 -2042 6823 4756 6047 9913 | -0902 -0215 |

3 | -2168 +0280 3207 5791 3638 9550 | +0989 -1626 |

4 | -2491 +0965 2884 7511 2033 9357 | -0065 -1941 |

5 | -0656 +1337 0162 2023 1192 9133 | +1255 -2381 |

### Notes and Tips

- Multiple values written or read on/from the same line will be separated by a single space.
- Each line ends with a newline character '\n'.
- For this exercise, approximate solutions are accepted.
- Solutions with an absolute error smaller than 10 will be considered correct.

**The usage of the same method used in Exercise 6.1 with more iterations (e.g. 21 iterations) is recommended**. Other methods to square root approximation can be used, as long as:- It used only integers. Floating point numbers or the RISC-V square root instruction cannot be used.
- The approximation is as or more precise than the suggested method.

- It is best to work with distances in meters and time in nanoseconds, so that the provided input values do not cause overflow when using the proposed method and a good precision might be achieved.
- Problem Geometry:
- There are many ways to solve this exercise. Here, we propose an approach that uses the equation of a circle. Given that d
_{A}, d_{B}and d_{C}are the distances between your position and the satellites A, B and C, respectively:- x
^{2}+ y^{2}= d_{A}^{2}(Eq. 1) - x
^{2}+ (y - Y_{B})^{2}= d_{B}^{2}(Eq. 2) - (x - X
_{C})^{2}+ y^{2}= d_{C}^{2}(Eq. 3)

- x
- Using Equations 1 and 2:
- y = (d
_{A}^{2}+ Y_{B}^{2}- d_{B}^{2}) / 2Y_{B}(Eq. 4) - x = + sqrt(d
_{A}^{2}- y^{2}) OR - sqrt(d_{A}^{2}- y^{2}) (Eq. 5)

- y = (d
- To find the correct x, you can try both possible values in Equation 3 and check which one is closer to satisfying the equation.

- There are many ways to solve this exercise. Here, we propose an approach that uses the equation of a circle. Given that d
- You can test your code using the simulator's assistant from this link.