latlon2xyz.m

来自「JLAB is a set of Matlab functions I have」· M 代码 · 共 41 行

M
41
字号
function[x,y,z]=latlon2xyz(lat,lon,R)%LATLON2XYZ  Convert latitude and longitude into Cartesian coordinates.%%   [X,Y,Z]=LATLON2XYZ(LAT,LON) converts latitude and longitude of %   a position on the surface of a sphere into Cartesian coordinates.  %%   LAT and LON are in degrees and X, Y, and Z are in kilometers.%%   The Cartesian coordinate system is a right-handed system whose%   origin lies at the center of the sphere.  It is oriented with the %   Z-axis passing though the poles and the X-axis passing through%   the point LAT=0, LON=0.  %%   By default, the radius of the sphere is taken as RADEARTH.%   LATLON2XYZ(LAT,LON,R) uses a sphere of radius R, in kilometers,%   instead.%%   See also XYZ2LATLON.%   __________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2006 J.M. Lilly --- type 'help jlab_license' for details if strcmp(lat, '--t')    latlon2xyz_test,returnendif nargin==2    R=radearth;endphi=deg2rad(lat);th=deg2rad(lon);x=R.*cos(phi).*cos(th);y=R.*cos(phi).*sin(th);z=R.*sin(phi);function[]=latlon2xyz_test%   'latlon2xyz --t' runs a test.%reporttest(' LATLON2XYZ ',aresame())

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?