Sunday, March 3, 2013

Calculando el punto medio entre dos coordenadas

Para encontrar el punto medio de dos coordanadas, tomando como referencia esta pagina movable-type.co.uk


public static void midPoint(double lat1,double lon1,double lat2,double lon2){

    double dLon = Math.toRadians(lon2 - lon1);

    //convert to radians
    lat1 = Math.toRadians(lat1);
    lat2 = Math.toRadians(lat2);
    lon1 = Math.toRadians(lon1);

    double Bx = Math.cos(lat2) * Math.cos(dLon);
    double By = Math.cos(lat2) * Math.sin(dLon);
    double lat3 = Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By));
    double lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);

    //print out in degrees
    System.out.println(Math.toDegrees(lat3) + " " + Math.toDegrees(lon3));
}

1 comment:

  1. IGT Gaming, Casinos, and Games for sale in Maricopa
    Find your หารายได้เสริม complete list 바카라 사이트 of casinos, games and games at 1xbet korean IGT Gaming in Maricopa, https://sol.edu.kg/ Arizona. 1. Casinos in Casino at Residence apr casino

    ReplyDelete

SQLCIPHER PHP 7.4 UBUNTU

 This took me too much time to implement, after two hours of searching, I didnt found and documentation of how to compile sqlcipher support ...