Permalink
Browse files

Always do at least one iteration when solving for EA in Almanac.

  • Loading branch information...
1 parent ddbccea commit d5c464d59592c8d1e37af03052a7696e6e514184 @fnoble fnoble committed Mar 29, 2013
Showing with 5 additions and 5 deletions.
  1. +1 −1 include/almanac.h
  2. +4 −4 src/almanac.c
View
2 include/almanac.h
@@ -33,7 +33,7 @@ typedef struct {
double af1; /**< 1-order clock correction in seconds/second. */
u16 week; /**< GPS week number, modulo 1024. */
u8 prn; /**< PRN number of the satellite. */
- u8 healthy; /**< Satellite health status. */
+ u8 healthy; /**< Satellite health status. */
} almanac_t;
/** \} */
View
8 src/almanac.c
@@ -66,15 +66,15 @@ void calc_sat_state_almanac(almanac_t* alm, double t, s16 week,
/* Iteratively solve for the Eccentric Anomaly
* (from Keith Alter and David Johnston). */
double ea = ma; /* Starting value for E. */
- double ea_old = ea + 1;
+ double ea_old;
double temp;
- while (fabs(ea - ea_old) > 1.0e-14)
- {
+ do {
ea_old = ea;
temp = 1.0 - alm->ecc * cos(ea_old);
ea = ea + (ma - ea_old + alm->ecc * sin(ea_old)) / temp;
- }
+ } while (fabs(ea - ea_old) > 1.0e-14);
+
double ea_dot = ma_dot / temp;
/* Begin calculation for True Anomaly and Argument of Latitude. */

0 comments on commit d5c464d

Please sign in to comment.