shared-snippets/matlab/unitutils/deg2km.m

31 lines
1.1 KiB
Matlab

%
% -----------------
% Copyright © 2022 ACK Cyfronet AGH, Poland.
% -----------------
%
function km = deg2km(deg)
%DEG2KM Convert distance from degrees to kilometers
%
% KM = DEG2KM(DEG) converts distances from degrees to kilometers as
% measured along a great circle on a sphere with a radius of 6371 km, the
% mean radius of the Earth.
%
% KM = DEG2KM(DEG,RADIUS) converts distances from degrees to kilometers
% as measured along a great circle on a sphere having the specified
% radius. RADIUS must be in units of kilometers.
%
% KM = DEG2KM(DEG,SPHERE) converts distances from degrees to kilometers,
% as measured along a great circle on a sphere approximating an object in
% the Solar System. SPHERE may be one of the following strings: 'sun',
% 'moon', 'mercury', 'venus', 'earth', 'mars', 'jupiter', 'saturn',
% 'uranus', 'neptune', or 'pluto', and is case-insensitive.
%
% See also DEG2NM, DEGTORAD, DEG2SM, KM2DEG.
% Copyright 1996-2009 The MathWorks, Inc.
% $Revision: 1.10.4.4 $ $Date: 2009/03/30 23:38:09 $
rad = deg2rad(deg);
km = rad*6371;