Hallo zusammen
hier noch ein C-script:
-------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
float PI=3.14159;
// Calulate the distance between to co-ordinates in degrees
float check_distance(float lat1, float lon1, float lat2, float lon2)
{
// returns a value in kilometres
return 1.852 * 2 * asin( sqrt( pow(sin((lat1/180*PI-lat2/180*PI)/2),2) + cos(lat1/180*PI)*cos(lat2/180*PI)* pow(sin((lon1/180*PI-lon2/180*PI)/2),2)))*180*60/PI;
}
// Calulate the distance between to co-ordinates in degrees
float check_distance1(float lat1, float lon1, float lat2, float lon2)
{
// returns a value in kilometres
return 100*(acos(sin(lat2)*sin(lat1)+cos(lat2)*cos(lat1)*cos(lon2 - lon1)));
}
// Calulate the distance between to co-ordinates in degrees
float check_distance2(float lat1, float lon1, float lat2, float lon2)
{
// returns a value in kilometres
return 100*(sqrt(((lat2 - lat1)*(lat2 - lat1)) + ((lon2 - lon1)*(lon2 - lon1))));
}
int main (int argc, const char * argv[]) {
float lat1=52.675321;
float lon1=9.4782611;
float lat2=52.6626576;
float lon2=9.48305922;
printf("distance: %f \n",check_distance(lat1,lon1,lat2,lon2));
printf("distance1: %f \n",check_distance1(lat1,lon1,lat2,lon2));
printf("distance2: %f \n",check_distance2(lat1,lon1,lat2,lon2));
//controll it on
http://gpsvisualizer.com/calculators
return 0;
}