直接vincenty算法的matlab代码-经纬度方位距离推算

  • JOHNCLOCK
    了解作者
  • matlab
    开发工具
  • 1.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 5 积分
    下载积分
  • 0
    下载次数
  • 2022-10-07 20:35
    上传日期
使用Vincenty高精度算法,根据现在点经纬度和相对点的方位距离,推算相对点的经纬度,是导航领域的常见问题。
vincentyDirect.m.zip
  • vincentyDirect.m
    1.5KB
内容介绍
function [latDest, lonDest, alpha2] = vincentyDirect(lat, lon, distance, initialBearing) alpha1 = initialBearing/180*pi; s = distance; a = 6378137.0; f = 1/298.257223563; b = a*(1-f); sinalpha1 = sin(alpha1); cosalpha1 = cos(alpha1); tanU1 = (1-f) * tan(lat); cosU1 = 1 / sqrt((1 + tanU1*tanU1)); sinU1 = tanU1 * cosU1; sigma1 = atan2(tanU1, cosalpha1); sinalpha = cosU1 * sinalpha1; cosSqalpha = 1 - sinalpha*sinalpha; uSq = cosSqalpha * (a*a - b*b) / (b*b); A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq))); B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq))); sigma = s / (b*A); sigmap = 1000; iterations = 1; while (abs(sigma-sigmap) > 1e-12 && iterations < 100) cos2sigmam = cos(2*sigma1 + sigma); sinsigma = sin(sigma); cossigma = cos(sigma); del_sigma = B*sinsigma*(cos2sigmam+B/4*(cossigma*(-1+2*cos2sigmam*cos2sigmam)... -B/6*cos2sigmam*(-3+4*sinsigma*sinsigma)*(-3+4*cos2sigmam*cos2sigmam))); sigmap = sigma; sigma = s / (b*A) + del_sigma; iterations = iterations + 1; end x = sinU1*sinsigma - cosU1*cossigma*cosalpha1; lat2 = atan2(sinU1*cossigma + cosU1*sinsigma*cosalpha1, (1-f)*sqrt(sinalpha*sinalpha + x*x)); lambda = atan2(sinsigma*sinalpha1, cosU1*cossigma - sinU1*sinsigma*cosalpha1); C = f/16*cosSqalpha*(4+f*(4-3*cosSqalpha)); L = lambda - (1-C) * f * sinalpha * (sigma + C*sinsigma*(cos2sigmam+C*cossigma*(-1+2*cos2sigmam*cos2sigmam))); lon2 = lon + L; latDest = lat2; lonDest = lon2; alpha2 = atan2(sinalpha, -x);
评论
    相关推荐