Incorporated Durk's Astro/ tweaks. Includes unifying the sun position

calculation code between sun display, and other FG sections that use this
for things like lighting.
This commit is contained in:
curt
2009-09-15 18:31:29 +02:00
committed by Tim Moore
parent 3e386f51a1
commit 20cf326fec
7 changed files with 186 additions and 210 deletions
+32 -49
View File
@@ -36,48 +36,12 @@
struct OrbElements pltOrbElements[9];
//double fgCalcActTime(struct fgTIME t)
//{
// double
// actTime, UT;
// int year;
//
// /* a hack. This one introduces the 2000 problem into the program */
// year = t.gmt->tm_year + 1900;
//
// /* calculate the actual time, remember to add 1 to tm_mon! */
// actTime = 367 * year - 7 *
// (year + ((t.gmt->tm_mon+1) + 9) / 12) / 4 + 275 *
// (t.gmt->tm_mon+1) / 9 + t.gmt->tm_mday - 730530;
//
// UT = t.gmt->tm_hour + ((double) t.gmt->tm_min / 60);
// /*printf("UT = %f\n", UT); */
// actTime += (UT / 24.0);
// #define DEBUG 1
// #ifdef DEBUG
// /* printf(" Actual Time:\n"); */
// /* printf(" current day = %f\t", actTime); */
// /* printf(" GMT = %d, %d, %d, %d, %d, %d\n",
// year, t.gmt->tm_mon, t.gmt->tm_mday,
// t.gmt->tm_hour, t.gmt->tm_min, t.gmt->tm_sec); */
// #endif
// return actTime;
//}
double fgCalcActTime(struct fgTIME t)
{
return (t.mjd - 36523.5);
}
/* convert degrees to radians */
/*
double fgDegToRad(double angle)
{
return (angle * PIOVER180);
}
*/
double fgCalcEccAnom(double M, double e)
{
double
@@ -101,16 +65,26 @@ double fgCalcEccAnom(double M, double e)
}
// This function assumes that if the FILE ptr is valid that the contents
// will be valid. Should we check the file for validity?
/* This function assumes that if the FILE ptr is valid that the
contents will be valid. Should we check the file for validity? */
/* Sounds like a good idea to me. What type of checks are you thinking
of, other than feof(FILE*)? That's currently the only check I can
think of (Durk) */
void fgReadOrbElements(struct OrbElements *dest, FILE *src)
int fgReadOrbElements(struct OrbElements *dest, FILE *src)
{
char line[256];
int i,j;
j = 0;
do
{
if (feof (src)) {
fgPrintf (FG_ASTRO, FG_ALERT,
"End of file found while reading planetary positions:\n");
return 0;
}
fgets(line, 256,src);
for (i = 0; i < 256; i++)
{
@@ -127,6 +101,8 @@ void fgReadOrbElements(struct OrbElements *dest, FILE *src)
&dest->aFirst, &dest->aSec,
&dest->eFirst, &dest->eSec,
&dest->MFirst, &dest->MSec);
return(1);
}
@@ -159,7 +135,9 @@ int fgSolarSystemInit(struct fgTIME t)
for (i = 0; i < 9; i ++)
{
/* ...read from the data file ... */
fgReadOrbElements(&pltOrbElements[i], data);
if (!(fgReadOrbElements (&pltOrbElements[i], data))) {
ret_val = 0;
}
/* ...and calculate the actual values */
fgSolarSystemUpdate(&pltOrbElements[i], t);
}
@@ -177,20 +155,25 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
actTime = fgCalcActTime(t);
/* calculate the actual orbital elements */
planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime)); // angle in radians
planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime)); // angle in radians
planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime)); // angle in radians
planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime)); // angle in radians
planet->e = planet->eFirst + (planet->eSec * actTime);
planet->a = planet->aFirst + (planet->aSec * actTime);
planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime));
planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime));
planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime));
planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime));
planet->e = planet->eFirst + (planet->eSec * actTime);
planet->a = planet->aFirst + (planet->aSec * actTime);
}
/* $Log$
/* Revision 1.7 1998/02/12 21:59:33 curt
/* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* Revision 1.8 1998/02/23 19:07:55 curt
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
/* calculation code between sun display, and other FG sections that use this
/* for things like lighting.
/*
* Revision 1.7 1998/02/12 21:59:33 curt
* Incorporated code changes contributed by Charlie Hotchkiss
* <chotchkiss@namg.us.anritsu.com>
*
* Revision 1.6 1998/02/03 23:20:11 curt
* Lots of little tweaks to fix various consistency problems discovered by
* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper