The great circle distance is the distance between two points on the surface of a sphere.
Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points on the sphere. The average earth radius is 6371.01 km. The great circle distance between the two points can be computed using the following formula:
d = radius * arccos(sin(point1.x) * sin(point2.x) + cos(point1.x) * cos(point2.x) * cos(point1.y – point2.y))
You can find trigonometric functions such as acos, sin, and cos in the math library.
Notes:
radius should be hardcoded in the method.
You will need to convert the degrees into radians using the Math.toRadians method since the Java trigonometric methods use radians.
The latitude and longitude degrees in the formula are for north and west. Use negative to indicate south and east.
Point Class
The point class simplifies the formal parameters of the CalculateGreatCircleDistance method. Instead of passing in four parameters for x and y of both points, we only pass in two parameters point1 and point2. This allows us to keep the number of parameters under the conventional maximum of 3. Three is not a hard limit from the programming language but a limit imposed for good code quality standards. Clients (i.e. you) can reference the individual x and y from the point class as the example shows below.
point.x point.y
Required Tasks
To complete this assignment you must do the following:
Finish calculateGreatCircleDistance in GreatCircle.java
Have at least 80% code coverage.
Choose 2 points and calculate the distance by hand. Then put a copy of file of your hand calculations called "calculations.png" in the /submissions folder.