Tentukan jarak antara dua lingkaran di java
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 r = 6371.0;
double deltax = x2 - x1;
double deltay = y2 - y1;
double term1 = Math.pow(Math.sin(deltax / 2), 2);
double term2 = Math.cos(x1) * Math.cos(x2) * Math.pow(Math.sin(deltay / 2), 2);
double sqrt = Math.sqrt((term1 + term2));
double distance = 2 * r * (Math.asin(sqrt));
Math.toDegrees(distance);
System.out.println(distance + " kilometers");
}
Dull Dotterel