采用墨卡托法计算:
?MATLAB代码:
function d = d(phi_F, lambda_F, phi_T, lambda_T)
%计算起始点和到达点的纬度渐常率
MP_T = 10800 / pi * log(tand(45 + phi_T / 2 ));
MP_F = 10800 / pi * log(tand(45+ phi_F / 2 ));
%计算恒向线航向角(半圆航向数值)
%注意:如果经度差大于180度,走劣弧
if abs(lambda_T - lambda_F) > 180
C = atand(60*(360 - abs(lambda_T - lambda_F)) / (MP_T - MP_F));
else
C = atand(60*(lambda_T - lambda_F) / (MP_T - MP_F));
end
if C < 0
C = 180 + C;
end
%输入半圆航向后缀名,转化为圆周航向数值
X = input("输入前后缀名:\n",'s');
switch X
case "NE"
C = C;
case "SE"
C = 180 - C;
case "SW"
C = 180 + C;
case "NW"
C = 360 - C;
end
%计算恒向线航程
if C == 90
d = (lambda_T - lambda_F) * cosd((phi_T - phi_F));
else
d = abs((phi_T - phi_F) * secd(C));
end
fprintf("恒向线航向为%f\n", C)
fprintf("恒向线航程为%f°,即%f′",d ,d * 60)
end
关于参数的注释可以参考上一篇文章:https://blog.csdn.net/weixin_58587245/article/details/121573573https://blog.csdn.net/weixin_58587245/article/details/121573573https://blog.csdn.net/weixin_58587245/article/details/121573573
|