方位角と緯度および経度の間の距離を計算します

#define PI 3.14159265358979323846
#define EARTH_RADIUS_L 6378137
#define EARTH_RADIUS_S 6356752.3142

/ * //角度からラジアン* /
static double rad(double d)
{     return d * PI / 180.0; } / * //ラジアンからラジアン* / static double deg(double x){     return x * 180 / PI; } / * // 2点間の距離を取得します* / double getDistance(double lat1、double lng1、double lat2、double lng2){     double radLat1 = rad(lat1);     double radLat2 = rad(lat2);     double a = radLat1-radLat2 ;     double b = rad(lng1)-rad(lng2);













    double s = 2 * asin(sqrt(pow(sin(a / 2)、2)+
        cos(radLat1)* cos(radLat2)* pow(sin(b / 2)、2)));
    s = s * EARTH_RADIUS_L;

    戻り値;
}

 

/ * //计算航向角* /
doubleCalculateHeading(double plng1、double plat1、double plng2、double plat2)
{     double y = sin(plng2-plng1)* cos(plat2);     double x = cos(plat1)* sin(plat2)-sin(plat1)* cos(plat2)* cos(plng2-plng1);     二重見出し= atan2(y、x);     heading = deg(heading); / * //変換化是比* /     if(heading <0)     {         heading = heading + 360;     }







    見出しを返します。
}

おすすめ

転載: blog.csdn.net/wyyy2088511/article/details/108586473