mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
conversions: fix return code for ECEF2LLA
As pointed out by osnwt in the forum, the criteria for success of this function was wrong. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1456 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
f202884ce8
commit
78befcba73
@ -60,6 +60,7 @@ uint16_t ECEF2LLA(double ECEF[3], double LLA[3])
|
|||||||
double x=ECEF[0], y=ECEF[1], z=ECEF[2];
|
double x=ECEF[0], y=ECEF[1], z=ECEF[2];
|
||||||
double Lat, N, NplusH, delta, esLat;
|
double Lat, N, NplusH, delta, esLat;
|
||||||
uint16_t iter;
|
uint16_t iter;
|
||||||
|
#define MAX_ITER 100
|
||||||
|
|
||||||
LLA[1] = RAD2DEG*atan2(y,x);
|
LLA[1] = RAD2DEG*atan2(y,x);
|
||||||
N = a;
|
N = a;
|
||||||
@ -68,7 +69,7 @@ uint16_t ECEF2LLA(double ECEF[3], double LLA[3])
|
|||||||
Lat = 1;
|
Lat = 1;
|
||||||
iter=0;
|
iter=0;
|
||||||
|
|
||||||
while (((delta > 1.0e-14)||(delta < -1.0e-14)) && (iter < 100))
|
while (((delta > 1.0e-14)||(delta < -1.0e-14)) && (iter < MAX_ITER))
|
||||||
{
|
{
|
||||||
delta = Lat - atan(z / (sqrt(x*x + y*y)*(1-(N*e*e/NplusH))));
|
delta = Lat - atan(z / (sqrt(x*x + y*y)*(1-(N*e*e/NplusH))));
|
||||||
Lat = Lat-delta;
|
Lat = Lat-delta;
|
||||||
@ -81,8 +82,7 @@ uint16_t ECEF2LLA(double ECEF[3], double LLA[3])
|
|||||||
LLA[0] = RAD2DEG*Lat;
|
LLA[0] = RAD2DEG*Lat;
|
||||||
LLA[2] = NplusH - N;
|
LLA[2] = NplusH - N;
|
||||||
|
|
||||||
if (iter==500) return (0);
|
return (iter < MAX_ITER);
|
||||||
else return (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****** find ECEF to NED rotation matrix ********
|
// ****** find ECEF to NED rotation matrix ********
|
||||||
|
Loading…
x
Reference in New Issue
Block a user