Problem C
Tunnelling the Earth

There are different methods of transporting people from place to place: cars, bikes, boats, trains, planes, etc. For very long distances, people generally fly in a plane. But this has the disadvantage that the plane must fly around the curved surface of the earth. A distance travelled would be shorter if the traveller followed a straight line from one point to the other through a tunnel through the earth.

For example, travelling from Waterloo to Cairo requires a distance of $9\, 293\, 521$ metres following the great circle route around the earth, but only $8\, 491\, 188$ metres following the straight line through the earth.

For this problem, assume that the earth is a perfect sphere with radius of exactly $6\, 371\, 009$ metres.


The first line of input contains a single integer $1 \le T \le 1000$, the number of test cases to follow. Each test case is one line containing four floating point numbers $\text {lat}_1$, $\text {long}_1$, $\text {lat}_2$ and $\text {long}_2$ ($-90 \le \text {lat}_1, \text {lat}_2 \le 90$, $-180 \le \text {long}_1, \text {long}_2 \le 180$), where $\text {lat}_1$, $\text {long}_1$ are the latitude and longitude of the origin of the trip, and $\text {lat}_2, \text {long}_2$ are the latitude and longitude of the destination of the trip. All of these measurements are in degrees. Positive numbers indicate North latitude and East longitude, while negative numbers indicate South latitude and West longitude.


For each test case, output a line containing a single real number, the difference in the distance between the two points following the great circle route around the surface of the earth and following the straight line through the earth, in metres. Your answer should have an absolute or relative error of at most $10^{-7}$.

Sample Input 1 Sample Output 1
43.466667 -80.516667 30.058056 31.228889
CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
Ondřej Lhoták
Source Waterloo Programming Contest 2010-07-10
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in