tecefgd2.m

来自「GPS software toolbox for GPS receiver de」· M 代码 · 共 45 行

M
45
字号
%                             tecefgd2.m
%  Scope:   This MATLAB macro performs the transformation from ECEF to geodetic
%           coordinates for a given position by using an iterative process; 
%           WGS-84 constants are used.
%  Usage:   [lat,lon,alt] = tecefgd2(pecef)
%  Description of parameters:
%           pecef -  input, ECEF position, with components in meters
%           lat   -  output, latitude of the position, in radians
%           lon   -  output, longitude of the position, in radians
%           alt   -  output, altitude of the position, in meters
%  External Matlab macros used:  wgs84con
%  Last update:  11/05/99
%  Copyright (C) 1999 by LL Consulting. All Rights Reserved.

function  [lat,lon,alt] = tecefgd2(pecef)

wgs84con;
% global constants used:  a_smaxis, eccentr2, onemecc2

%  Initialization


tol = 0.01;
alt = 0.;
rn = a_smaxis;

%  Compute geodetic position

temp0 = sqrt(pecef(1)*pecef(1) + pecef(2)*pecef(2));
temp1 = pecef(3) / temp0;
oldalt = 1000.;
iter = 0;

while ( (abs(oldalt - alt) > 0.001) & (iter < 10) )
   iter = iter + 1;
   oldalt = alt;
   temp = temp1 * (rn + alt) / (rn*onemecc2 + alt);
   temp2 = temp * temp;
   sin2phi = temp2 / (temp2 + 1.);
   rn = a_smaxis / sqrt( 1. - eccentr2 * sin2phi);
   alt = temp0 * sqrt(1. + temp2) - rn;
end

lat = atan(temp);
lon = atan2(pecef(2) , pecef(1));

⌨️ 快捷键说明

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