Horje
determine the distance between two circles in java Code Example
determine the distance between two circles in 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");
    }




Java

Related
java lambda expression in priorityqueue Code Example java lambda expression in priorityqueue Code Example
double to string in java without tovalue Code Example double to string in java without tovalue Code Example
how to make 2d array of strings in java Code Example how to make 2d array of strings in java Code Example
align button to the left in JPanel Code Example align button to the left in JPanel Code Example
error message pushes button down Code Example error message pushes button down Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9