1. If the search result has the coordinates then the distance to the midpoint is calculated by:
Since you only can use integer numbers the value of d must be truncated. (Depending on the programming language you use the command should be something like trunc(d) or floor(d) or ...)
2. With the coordinates of R you can calulate the angle between the positive x-axis starting at the midpoint:
With this value you can determine the value of .
You have to consider 2 cases:
The 3'o clock position must be located in the sector of