Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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");
    }
Comment

PREVIOUS NEXT
Code Example
Java :: javafx treeview directory 
Java :: jumping sequence java boolean values 
Java :: How to adjust layout when soft keyboard appears 
Java :: Example of "this" : to invoke current class method 
Java :: Java extract string between two strings 
Java :: aaa testing java 
Java :: cannot apply java lang integer android 
Java :: Java List Replace at Index using set() function 
Java :: final variables in java 
Java :: java byte array to blob 
Java :: query spring boot 
Java :: import class java 
Java :: java lambda function 
Java :: java string stringbuilder remove trailing comma 
Java :: java tutorialspoint 
Java :: how to set default color in android studio 
Java :: how to sprint minecraft java 
Java :: number of matches regex java 
Java :: Access HashMap Elements 
Java :: coin flip in java 
Java :: android MediaStore update cache before query 
Sql :: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning. 
Sql :: oracle nls_date_format 
Sql :: oracle get table schema 
Sql :: mysql change user password 
Sql :: oracle columns in all_tables 
Sql :: sql server get users 
Sql :: cast string to datetime mysql 
Sql :: .... ERROR! The server quit without updating PID file mysql centos 
Sql :: search stored procedures by name 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =