Starting git repo for working on files
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
public class GreatCircle
|
||||
{
|
||||
public static void main(String [] args){
|
||||
|
||||
|
||||
double x1 = Math.toRadians(Double.parseDouble(args[0]));
|
||||
double y1 = Math.toRadians(Double.parseDouble(args[1]));
|
||||
double x2 = Math.toRadians(Double.parseDouble(args[2]));
|
||||
double y2 = Math.toRadians(Double.parseDouble(args[3]));
|
||||
|
||||
double t1 = (x2 - x1) / 2.0;
|
||||
double t2 = (y2 - y1) / 2.0;
|
||||
double q1 = Math.pow(Math.sin(t1), 2);
|
||||
double q2 = Math.pow(Math.sin(t2), 2);
|
||||
|
||||
double as = q1 + (Math.cos(x1) * Math.cos(x2) * q2);
|
||||
double sq = Math.sqrt(as);
|
||||
|
||||
double distance = 2 * 6371.0 * Math.asin(sq);
|
||||
|
||||
System.out.println(distance + " kilometers");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user