45 char names[][
MAX_NAME] = {
"rearth",
"kep2eci",
"eci2kep"}; 
    46 int i, jumpto = -1, skip = -1; 
    47 double error, adjerror,avgerror, minerror, maxerror, terror, tminerror, tmaxerror;
    48 error = adjerror = avgerror = minerror = maxerror = terror = tminerror = tmaxerror = 0.;
    51     if (strcmp(argv[1], names[i]) == 0) { 
    53     printf(
"\nFunctionality Test:\t%s\n\n", names[i]);
    55     } 
else if ((*argv[1] == 
'-')&&(strcmp(&argv[1][1], names[i]) == 0)) {
    58     printf(
"\nFunctionality Tests:\tconvertlib (without %s)\n\n", names[i]);
    69     printf(
"\nFunctionality Tests:\tconvertlib\n\n");
    72     printf(
"Function: rearth()\n");
    78         fscanf(LATvRdata, 
"%d", &numTests);
    80         double lat, rad, maxErrorL, minErrorL, maxErrorR, minErrorR;
    81         error = adjerror = avgerror = 0.0;
    82         printf(
"Latitude:                \tRadius(function):\tRadius(correct):\t  Delta:\n");
    83         printf(
"(deg)\t(rad)             \t(m)\t\t\t(m)\t\t\t  (m)\n");
    84         while (i<numTests&&!feof(LATvRdata)) {
    85             fscanf(LATvRdata, 
"%lf%lf", &lat, &rad);
    88                 minerror = maxerror = error;
    89                 maxErrorL = minErrorL = lat;
    90                 maxErrorR = minErrorR = rad;
    91             } 
else if (fabs(error)>fabs(maxerror)) {
    95             } 
else if (fabs(error)<fabs(minerror)) {
   100             avgerror += fabs(error);
   101             adjerror = avgerror/rad;
   103                 printf(
"%0.0f \t%0.15f\t%0.9f  (-)  %0.9f (=) %11.5g\n", 
DEGOF(lat), lat, 
rearth(lat), rad, error);
   108         printf(
"%d tests total.  One out of every %d shown.\n",i,z);
   110         adjerror = adjerror/
i;
   111         avgerror = avgerror/
i;
   112         printf(
"Max Error:%0.0f \t%0.15f\t%0.9f  (-)  %0.9f (=) %11.5g\n", 
DEGOF(maxErrorL), maxErrorL, 
rearth(maxErrorL), maxErrorR, maxerror);
   113         printf(
"Min Error:%0.0f \t%0.15f\t%0.9f  (-)  %0.9f (=) %11.5g\n", 
DEGOF(minErrorL), minErrorL, 
rearth(minErrorL), minErrorR, minerror);
   114         printf(
"Average Error:%11.5g\tAdjusted Error:%11.5g\n", avgerror, adjerror);
   117         printf(
"rearth() Error: %11.5g\tTerror:%11.5g\n",adjerror, terror);
   120     if (jumpto!=-1) 
break; 
   124     printf(
"Function: kep2eci()\n");
   125     if (jumpto!=-1) 
break;
   129     printf(
"Function: eci2kep()\n");
   134         fscanf(KeplerData, 
"%d", &numTests);
   136         kepstruc kepcorrect, keptest, Kmaxerror, Kminerror;
   137         cartpos eciinput, Emaxerror, Eminerror;
   140         printf(
"ECI vector input |#|Kepler element output\n");
   141         while (i<numTests&&(!feof(KeplerData)||!feof(ECIData))) {
   142             fscanf(KeplerData, 
"%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &kepcorrect.
beta, &kepcorrect.
period, &kepcorrect.
alat, &kepcorrect.
ap, &kepcorrect.
ea, &kepcorrect.
e, &kepcorrect.
h.
col[0], &kepcorrect.
fa, &kepcorrect.
i, &kepcorrect.
ma, &kepcorrect.
mm, &kepcorrect.
raan, &kepcorrect.
a, &kepcorrect.
ta);
   144             fscanf(ECIData, 
"%lf%lf%lf%lf%lf%lf%lf%lf%lf", &eciinput.
s.
col[0], &eciinput.
s.
col[1], &eciinput.
s.
col[2], &eciinput.
v.
col[0], &eciinput.
v.
col[1], &eciinput.
v.
col[2], &eciinput.
a.
col[0], &eciinput.
a.
col[1], &eciinput.
a.
col[2]);
   145             eciinput.
utc = 55927;
   147             error = fabs(keptest.
beta - kepcorrect.
beta)+fabs(keptest.
period - kepcorrect.
period)+fabs(keptest.
alat - kepcorrect.
alat)+fabs(keptest.
ap - kepcorrect.
ap)+fabs(keptest.
ea - kepcorrect.
ea)+fabs(keptest.
e - kepcorrect.
e)+fabs(keptest.
fa - kepcorrect.
fa)+fabs(keptest.
i - kepcorrect.
i)+fabs(keptest.
ma - kepcorrect.
ma)+fabs(keptest.
mm - kepcorrect.
mm)+fabs(keptest.
raan - kepcorrect.
raan)+fabs(keptest.
a - kepcorrect.
a)+fabs(keptest.
ta - kepcorrect.
ta);
   149                 minerror = maxerror = error;
   150                 Kmaxerror = Kminerror = kepcorrect;
   151                 Emaxerror = Eminerror = eciinput;
   152             } 
else if (fabs(error)>fabs(maxerror)) {
   154                 Kmaxerror = kepcorrect;
   155                 Emaxerror = eciinput;
   156             } 
else if (fabs(error)<fabs(minerror)) {
   158                 Kminerror = kepcorrect;
   159                 Eminerror = eciinput;
   161             avgerror += fabs(error);
   163                 printf(
"%d______________________________________________________________________________________________________________\n",i);
   164                 printf(
"pos x:%11.5g|#|         Beta Angle |Period     |alat       |arg per    |E anom     |e          |flight ang\n",eciinput.
s.
col[0]);
   165                 printf(
"    y:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",eciinput.
s.
col[1],keptest.
beta,keptest.
period,keptest.
alat,keptest.
ap,keptest.
ea,keptest.
e,keptest.
fa);
   166                 printf(
"    z:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",eciinput.
s.
col[2],kepcorrect.
beta,kepcorrect.
period,kepcorrect.
alat,kepcorrect.
ap,kepcorrect.
ea,kepcorrect.
e,kepcorrect.
fa);
   167                 printf(
"vel x:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",eciinput.
v.
col[0],(keptest.
beta-kepcorrect.
beta),(keptest.
period-kepcorrect.
period),(keptest.
alat-kepcorrect.
alat),(keptest.
ap-kepcorrect.
ap),(keptest.
ea-kepcorrect.
ea),(keptest.
e-kepcorrect.
e),(keptest.
fa-kepcorrect.
fa));
   168                 printf(
"    y:%11.5g|#|         i          |mean anom  |mean motion|raan       |a          |true anomaly           \n",eciinput.
v.
col[1]);
   169                 printf(
"    z:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",eciinput.
v.
col[2],keptest.
i,keptest.
ma,keptest.
mm,keptest.
raan,keptest.
a,keptest.
ta);
   170                 printf(
"acc x:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",eciinput.
a.
col[0],kepcorrect.
i,kepcorrect.
ma,kepcorrect.
mm,kepcorrect.
raan,kepcorrect.
a,kepcorrect.
ta);
   171                 printf(
"    y:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",eciinput.
a.
col[1],(keptest.
i-kepcorrect.
i),(keptest.
ma-kepcorrect.
ma),(keptest.
mm-kepcorrect.
mm),(keptest.
raan-kepcorrect.
raan),(keptest.
a-kepcorrect.
a),(keptest.
ta-kepcorrect.
ta));
   172                 printf(
"    z:%11.5g|#|\n",eciinput.
a.
col[2]);
   176         printf(
"________________________________________________________________________________________________________________\n");
   179         printf(
"\n%d tests total, one out of every %d shown.\n",i,z);
   180         avgerror = avgerror/
i;
   181         printf(
"\nMaximum Error:__________________________________________________________________________________________\n");
   183         printf(
"pos x:%11.5g|#|         Beta Angle |Period     |alat       |arg per    |E anom     |e          |flight ang\n",Emaxerror.
s.
col[0]);
   184         printf(
"    y:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Emaxerror.
s.
col[1],keptest.
beta,keptest.
period,keptest.
alat,keptest.
ap,keptest.
ea,keptest.
e,keptest.
fa);
   185         printf(
"    z:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Emaxerror.
s.
col[2],Kmaxerror.
beta,Kmaxerror.
period,Kmaxerror.
alat,Kmaxerror.
ap,Kmaxerror.
ea,Kmaxerror.
e,Kmaxerror.
fa);
   186         printf(
"vel x:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Emaxerror.
v.
col[0],(keptest.
beta-Kmaxerror.
beta),(keptest.
period-Kmaxerror.
period),(keptest.
alat-Kmaxerror.
alat),(keptest.
ap-Kmaxerror.
ap),(keptest.
ea-Kmaxerror.
ea),(keptest.
e-Kmaxerror.
e),(keptest.
fa-Kmaxerror.
fa));
   187         printf(
"    y:%11.5g|#|         i          |mean anom  |mean motion|raan       |a          |true anomaly           \n",Emaxerror.
v.
col[1]);
   188         printf(
"    z:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Emaxerror.
v.
col[2],keptest.
i,keptest.
ma,keptest.
mm,keptest.
raan,keptest.
a,keptest.
ta);
   189         printf(
"acc x:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Emaxerror.
a.
col[0],Kmaxerror.
i,Kmaxerror.
ma,Kmaxerror.
mm,Kmaxerror.
raan,Kmaxerror.
a,Kmaxerror.
ta);
   190         printf(
"    y:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Emaxerror.
a.
col[1],(keptest.
i-Kmaxerror.
i),(keptest.
ma-Kmaxerror.
ma),(keptest.
mm-Kmaxerror.
mm),(keptest.
raan-Kmaxerror.
raan),(keptest.
a-Kmaxerror.
a),(keptest.
ta-Kmaxerror.
ta));
   191         printf(
"    z:%11.5g|#|\n",Emaxerror.
a.
col[2]);
   192         printf(
"\nMinimum Error:__________________________________________________________________________________________\n");
   194         printf(
"pos x:%11.5g|#|         Beta Angle |Period     |alat       |arg per    |E anom     |e          |flight ang\n",Eminerror.
s.
col[0]);
   195         printf(
"    y:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Eminerror.
s.
col[1],keptest.
beta,keptest.
period,keptest.
alat,keptest.
ap,keptest.
ea,keptest.
e,keptest.
fa);
   196         printf(
"    z:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Eminerror.
s.
col[2],Kminerror.
beta,Kminerror.
period,Kminerror.
alat,Kminerror.
ap,Kminerror.
ea,Kminerror.
e,Kminerror.
fa);
   197         printf(
"vel x:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g\n",Eminerror.
v.
col[0],(keptest.
beta-Kminerror.
beta),(keptest.
period-Kminerror.
period),(keptest.
alat-Kminerror.
alat),(keptest.
ap-Kminerror.
ap),(keptest.
ea-Kminerror.
ea),(keptest.
e-Kminerror.
e),(keptest.
fa-Kminerror.
fa));
   198         printf(
"    y:%11.5g|#|         i          |mean anom  |mean motion|raan       |a          |true anomaly           \n",Eminerror.
v.
col[1]);
   199         printf(
"    z:%11.5g|#|function:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Eminerror.
v.
col[2],keptest.
i,keptest.
ma,keptest.
mm,keptest.
raan,keptest.
a,keptest.
ta);
   200         printf(
"acc x:%11.5g|#| correct:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Eminerror.
a.
col[0],Kminerror.
i,Kminerror.
ma,Kminerror.
mm,Kminerror.
raan,Kminerror.
a,Kminerror.
ta);
   201         printf(
"    y:%11.5g|#|   delta:%11.5g|%11.5g|%11.5g|%11.5g|%11.5g|%11.5g            \n",Eminerror.
a.
col[1],(keptest.
i-Kminerror.
i),(keptest.
ma-Kminerror.
ma),(keptest.
mm-Kminerror.
mm),(keptest.
raan-Kminerror.
raan),(keptest.
a-Kminerror.
a),(keptest.
ta-Kminerror.
ta));
   202         printf(
"    z:%11.5g|#|\n",Eminerror.
a.
col[2]);
   204     if (jumpto!=-1) 
break;
   207     printf(
"\nconvertlib total error");
   208     if (skip!=-1) printf(
" (without %s)",names[skip]); 
   209     printf(
":\t%11.5g\n",terror); 
 int openFileLine(FILE **fp, const char filename[], int startLine)
Definition: convert_test.cpp:213
double ta
True Anomoly. 
Definition: convertdef.h:557
int32_t eci2kep(cartpos &eci, kepstruc &kep)
Definition: convertlib.cpp:2934
double mm
Mean Motion. 
Definition: convertdef.h:561
rvector a
Acceleration. 
Definition: convertdef.h:167
double utc
UTC of Position. 
Definition: convertdef.h:161
int i
Definition: rw_test.cpp:37
double e
Eccentricity. 
Definition: convertdef.h:540
Cartesian full position structure. 
Definition: convertdef.h:158
double ma
Mean Anomoly. 
Definition: convertdef.h:555
rvector h
Angular Momentum vector. 
Definition: convertdef.h:542
#define MAX_NAME
Definition: convert_test.cpp:36
rvector s
Location. 
Definition: convertdef.h:163
double period
Orbital Period in seconds. 
Definition: convertdef.h:536
double fa
Definition: convertdef.h:562
#define DEGOF(rad)
Degrees of a Radian value. 
Definition: math/constants.h:33
double raan
Right Ascension of the Ascending Node in radians. 
Definition: convertdef.h:549
Classical elements structure. 
Definition: convertdef.h:529
double ap
Argument of Perigee. 
Definition: convertdef.h:551
double col[3]
Definition: vector.h:55
double i
Orbital Inclination in radians. 
Definition: convertdef.h:547
double beta
Solar Beta Angle in radians. 
Definition: convertdef.h:544
double a
Semi-Major Axis in meters. 
Definition: convertdef.h:538
void skipLines(FILE *fp, int lines)
Definition: convert_test.cpp:226
double ea
Eccentric Anomoly. 
Definition: convertdef.h:559
double rearth(double lat)
Definition: convertlib.cpp:1556
rvector v
Velocity. 
Definition: convertdef.h:165
double alat
Argument of Latitude. 
Definition: convertdef.h:553
#define RADOF(deg)
Radians of a Degree value. 
Definition: math/constants.h:29