Files
Earthquake/mydistance.m
2021-06-12 00:26:34 +03:00

25 lines
956 B
Matlab
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function out=mydistance(fiA,LA,fiB,LB) % расстояние по координатам
%% By L_DelOff
% out[км]=mydistance(fiA,LA,fiB,LB[всё градусы])
% cos(d) = sin(φА)·sin(φB) + cos(φА)·cos(φB)·cos(λА λB),
% где φА и φB — широты, λА, λB — долготы данных пунктов,
% d — расстояние между пунктами, измеряемое в радианах длиной дуги
% большого круга земного шара.
if LA>180
LA=LA-360;
end
if LB>180
LB=LB-360;
end
fiA=radians(fiA);
LA=radians(LA);
fiB=radians(fiB);
LB=radians(LB);
d = acos(sin(fiA)*sin(fiB) + cos(fiA)*cos(fiB)*cos(LA-LB));%
% Расстояние между пунктами, измеряемое в километрах,
% определяется по формуле:
% L = d·R,
% где R = 6371 км — средний радиус земного шара.
out=d*6371;
end