To version 0.29

This commit is contained in:
curt
2009-09-15 18:31:28 +02:00
committed by Tim Moore
parent 0e53f221cf
commit cb1bcb398a
8 changed files with 272 additions and 283 deletions
+54 -147
View File
@@ -40,113 +40,12 @@ struct CelestialCoord moonPos;
static float xMoon, yMoon, zMoon; static float xMoon, yMoon, zMoon;
static GLint moon; static GLint moon;
/*
static GLfloat vdata[12][3] =
{
{-X, 0.0, Z }, { X, 0.0, Z }, {-X, 0.0, -Z}, {X, 0.0, -Z },
{ 0.0, Z, X }, { 0.0, Z, -X}, {0.0, -Z, -X}, {0.0, -Z, -X},
{ Z, X, 0.0 }, { -Z, X, 0.0}, {Z, -X, 0.0 }, {-Z, -X, 0.0}
};
static GLuint tindices[20][3] =
{
{0,4,1}, {0,9,4}, {9,5,4}, {4,5,8}, {4,8,1},
{8,10,1}, {8,3,10}, {5,3,8}, {5,2,3}, {2,7,3},
{7,10,3}, {7,6,10}, {7,11,6}, {11,0,6}, {0,1,6},
{6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11}
};*/
/* -------------------------------------------------------------
This section contains the code that generates a yellow
Icosahedron. It's under development... (of Course)
______________________________________________________________*/
/*
void NormalizeVector(float v[3])
{
GLfloat d = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
if (d == 0.0)
{
printf("zero length vector\n");
return;
}
v[0] /= d;
v[1] /= d;
v[2] /= d;
}
void drawTriangle(float *v1, float *v2, float *v3)
{
xglBegin(GL_POLYGON);
//xglBegin(GL_POINTS);
xglNormal3fv(v1);
xglVertex3fv(v1);
xglNormal3fv(v2);
xglVertex3fv(v2);
xglNormal3fv(v3);
xglVertex3fv(v3);
xglEnd();
}
void subdivide(float *v1, float *v2, float *v3, long depth)
{
GLfloat v12[3], v23[3], v31[3];
GLint i;
if (!depth)
{
drawTriangle(v1, v2, v3);
return;
}
for (i = 0; i < 3; i++)
{
v12[i] = (v1[i] + v2[i]);
v23[i] = (v2[i] + v3[i]);
v31[i] = (v3[i] + v1[i]);
}
NormalizeVector(v12);
NormalizeVector(v23);
NormalizeVector(v31);
subdivide(v1, v12, v31, depth - 1);
subdivide(v2, v23, v12, depth - 1);
subdivide(v3, v31, v23, depth - 1);
subdivide(v12, v23, v31,depth - 1);
} */
/*
void display(void)
{
int i;
xglClear(GL_COLOR_BUFFER_BIT);
xglPushMatrix();
xglRotatef(spin, 0.0, 0.0, 0.0);
xglColor3f(1.0, 1.0, 0.0);
// xglBegin(GL_LINE_LOOP);
for (i = 0; i < 20; i++)
{
//xglVertex3fv(&vdata[tindices[i][0]][0]);
//xglVertex3fv(&vdata[tindices[i][1]][0]);
//xglVertex3fv(&vdata[tindices[i][2]][0]);
subdivide(&vdata[tindices[i][0]][0],
&vdata[tindices[i][1]][0],
&vdata[tindices[i][2]][0], 3);
}
// xglEnd();
// xglFlush();
xglPopMatrix();
glutSwapBuffers();
} */
/* -------------------------------------------------------------- /* --------------------------------------------------------------
This section contains the code that calculates the actual This section contains the code that calculates the actual
position of the moon in the night sky. position of the moon in the night sky.
----------------------------------------------------------------*/ ----------------------------------------------------------------*/
struct CelestialCoord fgCalculateMoon(struct OrbElements params, struct CelestialCoord fgCalculateMoon(struct OrbElements params,
struct OrbElements sunParams, struct OrbElements sunParams,
struct fgTIME t) struct fgTIME t)
@@ -154,7 +53,6 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
struct CelestialCoord struct CelestialCoord
geocCoord, topocCoord; geocCoord, topocCoord;
double double
eccAnom, ecl, lonecl, latecl, actTime, eccAnom, ecl, lonecl, latecl, actTime,
xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze, xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
@@ -166,14 +64,16 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
a = &current_aircraft; a = &current_aircraft;
f = &a->flight; f = &a->flight;
/* calculate the angle between ecliptic and equatorial coordinate system */ /* calculate the angle between ecliptic and equatorial coordinate
* system, in Radians */
actTime = fgCalcActTime(t); actTime = fgCalcActTime(t);
ecl = fgDegToRad(23.4393 - 3.563E-7 * actTime); // in radians of course /* ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);*/
ecl = 0.409093 - 6.2186E-9 * actTime;
/* calculate the eccentric anomaly */ /* calculate the eccentric anomaly */
eccAnom = fgCalcEccAnom(params.M, params.e); eccAnom = fgCalcEccAnom(params.M, params.e);
/* calculate the moon's distance (d) and true anomaly (v) */ /* calculate the moon's distance (r) and true anomaly (v) */
xv = params.a * ( cos(eccAnom) - params.e); xv = params.a * ( cos(eccAnom) - params.e);
yv = params.a * ( sqrt(1.0 - params.e*params.e) * sin(eccAnom)); yv = params.a * ( sqrt(1.0 - params.e*params.e) * sin(eccAnom));
v =atan2(yv, xv); v =atan2(yv, xv);
@@ -188,39 +88,41 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
lonecl = atan2( yh, xh); lonecl = atan2( yh, xh);
latecl = atan2( zh, sqrt( xh*xh + yh*yh)); latecl = atan2( zh, sqrt( xh*xh + yh*yh));
/* calculate a number of perturbations */ /* calculate a number of perturbations, i.e. disturbances caused by
* the gravitational influence of the sun and the other mayor
* planets, the largest even have their own names */
Ls = sunParams.M + sunParams.w; Ls = sunParams.M + sunParams.w;
Lm = params.M + params.w + params.N; Lm = params.M + params.w + params.N;
D = Lm - Ls; D = Lm - Ls;
F = Lm - params.N; F = Lm - params.N;
lonecl += fgDegToRad( lonecl += DEG_TO_RAD * (
- 1.274 * sin (params.M - 2*D) // the Evection - 1.274 * sin (params.M - 2*D) /* the Evection */
+ 0.658 * sin (2 * D) // the Variation + 0.658 * sin (2 * D) /* the Variation */
- 0.186 * sin (sunParams.M) // the yearly variation - 0.186 * sin (sunParams.M) /* the yearly variation */
- 0.059 * sin (2*params.M - 2*D) - 0.059 * sin (2*params.M - 2*D)
- 0.057 * sin (params.M - 2*D + sunParams.M) - 0.057 * sin (params.M - 2*D + sunParams.M)
+ 0.053 * sin (params.M + 2*D) + 0.053 * sin (params.M + 2*D)
+ 0.046 * sin (2*D - sunParams.M) + 0.046 * sin (2*D - sunParams.M)
+ 0.041 * sin (params.M - sunParams.M) + 0.041 * sin (params.M - sunParams.M)
- 0.035 * sin (D) // the Parallactic Equation - 0.035 * sin (D) /* the Parallactic Equation */
- 0.031 * sin (params.M + sunParams.M) - 0.031 * sin (params.M + sunParams.M)
- 0.015 * sin (2*F - 2*D) - 0.015 * sin (2*F - 2*D)
+ 0.011 * sin (params.M - 4*D) + 0.011 * sin (params.M - 4*D)
); /* Pheeuuwwww */ );
latecl += fgDegToRad( latecl += DEG_TO_RAD * (
- 0.173 * sin (F - 2*D) - 0.173 * sin (F - 2*D)
- 0.055 * sin (params.M - F - 2*D) - 0.055 * sin (params.M - F - 2*D)
- 0.046 * sin (params.M + F - 2*D) - 0.046 * sin (params.M + F - 2*D)
+ 0.033 * sin (F + 2*D) + 0.033 * sin (F + 2*D)
+ 0.017 * sin (2 * params.M + F) + 0.017 * sin (2 * params.M + F)
); /* Yep */ );
r += ( r += (
- 0.58 * cos(params.M - 2*D) - 0.58 * cos(params.M - 2*D)
- 0.46 * cos(2*D) - 0.46 * cos(2*D)
); /* Ok! */ );
xg = r * cos(lonecl) * cos(latecl); xg = r * cos(lonecl) * cos(latecl);
yg = r * sin(lonecl) * cos(latecl); yg = r * sin(lonecl) * cos(latecl);
zg = r * sin(latecl); zg = r * sin(latecl);
@@ -238,10 +140,11 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
/* New since 25 december 1997 */ /* New since 25 december 1997 */
/* Calculate the moon's topocentric position instead of it's geocentric! */ /* Calculate the moon's topocentric position instead of it's geocentric! */
mpar = asin( 1 / r); /* calculate the moon's parrallax, i.e. the apparent size of the /* calculate the moon's parrallax, i.e. the apparent size of the
(equatorial) radius of the Earth, as seen from the moon */ * (equatorial) radius of the Earth, as seen from the moon */
gclat = FG_Latitude - 0.083358 * sin (2 * fgDegToRad( FG_Latitude)); mpar = asin( 1 / r);
rho = 0.99883 + 0.00167 * cos(2 * fgDegToRad(FG_Latitude)); gclat = FG_Latitude - 0.083358 * sin (2 * DEG_TO_RAD * FG_Latitude);
rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * FG_Latitude);
if (geocCoord.RightAscension < 0) if (geocCoord.RightAscension < 0)
geocCoord.RightAscension += (2*FG_PI); geocCoord.RightAscension += (2*FG_PI);
@@ -259,22 +162,23 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
void fgMoonInit( void ) { void fgMoonInit( void ) {
struct fgLIGHT *l; /* struct fgLIGHT *l; */
static int dl_exists = 0; static int dl_exists = 0;
/* GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; */
GLfloat moonColor[4] = {0.85, 0.65, 0.05, 1.0};
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
fgPrintf( FG_ASTRO, FG_INFO, "Initializing the Moon\n"); fgPrintf( FG_ASTRO, FG_INFO, "Initializing the Moon\n");
l = &cur_light_params; /* l = &cur_light_params; */
/* position the moon */ /* position the moon */
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
cur_time_params); cur_time_params);
#ifdef DEBUG
fgPrintf( FG_ASTRO, FG_DEBUG, fgPrintf( FG_ASTRO, FG_DEBUG,
"Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension, "Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension,
moonPos.Declination); moonPos.Declination);
#endif
xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
@@ -290,7 +194,8 @@ void fgMoonInit( void ) {
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear); /* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
glutSolidSphere(1.0, 10, 10); glutSolidSphere(1.0, 10, 10);
@@ -301,15 +206,14 @@ void fgMoonInit( void ) {
/* Draw the moon */ /* Draw the moon */
void fgMoonRender( void ) { void fgMoonRender( void ) {
struct fgLIGHT *l; /* struct fgLIGHT *l; */
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
/* printf("Rendering moon\n"); */ /* printf("Rendering moon\n"); */
l = &cur_light_params; /* l = &cur_light_params; */
xglMaterialfv(GL_FRONT, GL_AMBIENT, l->sky_color ); /* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->sky_color ); */
xglMaterialfv(GL_FRONT, GL_DIFFUSE, white); /* xglMaterialfv(GL_FRONT, GL_DIFFUSE, white); */
xglPushMatrix(); xglPushMatrix();
xglTranslatef(xMoon, yMoon, zMoon); xglTranslatef(xMoon, yMoon, zMoon);
@@ -322,10 +226,13 @@ void fgMoonRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.4 1998/01/27 00:47:46 curt /* Revision 1.5 1998/02/02 20:53:21 curt
/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message /* To version 0.29
/* system and commandline/config file processing code.
/* /*
* Revision 1.4 1998/01/27 00:47:46 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
*
* Revision 1.3 1998/01/19 19:26:57 curt * Revision 1.3 1998/01/19 19:26:57 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously. * This should simplify things tremendously.
+8 -5
View File
@@ -31,14 +31,14 @@
#include <Time/fg_time.h> #include <Time/fg_time.h>
#include <math.h> #include <math.h>
#define X .525731112119133606 /* #define X .525731112119133606 */
#define Z .850650808352039932 /* #define Z .850650808352039932 */
/* Initialize the Moon Display management Subsystem */ /* Initialize the Moon Display management Subsystem */
void fgMoonInit( void ); void fgMoonInit( void );
/* Draw the Stars */ /* Draw the Moon */
void fgMoonRender( void ); void fgMoonRender( void );
struct CelestialCoord fgCalculateMoon(struct OrbElements Params, struct CelestialCoord fgCalculateMoon(struct OrbElements Params,
@@ -51,9 +51,12 @@ extern struct OrbElements pltOrbElements[9];
/* $Log$ /* $Log$
/* Revision 1.4 1998/01/22 02:59:27 curt /* Revision 1.5 1998/02/02 20:53:21 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* To version 0.29
/* /*
* Revision 1.4 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
* Revision 1.3 1998/01/19 19:26:58 curt * Revision 1.3 1998/01/19 19:26:58 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously. * This should simplify things tremendously.
+47 -36
View File
@@ -28,6 +28,7 @@
#include <Astro/orbits.h> #include <Astro/orbits.h>
#include <Include/fg_constants.h>
#include <Include/general.h> #include <Include/general.h>
#include <Time/fg_time.h> #include <Time/fg_time.h>
#include <Main/fg_debug.h> #include <Main/fg_debug.h>
@@ -35,40 +36,48 @@
struct OrbElements pltOrbElements[9]; 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) double fgCalcActTime(struct fgTIME t)
{ {
double return (t.mjd - 36523.5);
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, rember 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;
} }
/* convert degrees to radians */ /* convert degrees to radians */
/*
double fgDegToRad(double angle) double fgDegToRad(double angle)
{ {
return (angle * PIOVER180); return (angle * PIOVER180);
} }
*/
double fgCalcEccAnom(double M, double e) double fgCalcEccAnom(double M, double e)
{ {
double double
@@ -85,7 +94,7 @@ double fgCalcEccAnom(double M, double e)
diff = fabs(E0 - E1); diff = fabs(E0 - E1);
E0 = E1; E0 = E1;
} }
while (diff > fgDegToRad(0.001)); while (diff > (DEG_TO_RAD * 0.001));
return E0; return E0;
} }
return eccAnom; return eccAnom;
@@ -137,12 +146,11 @@ void fgSolarSystemInit(struct fgTIME t)
if ( (data = fopen(path, "r")) == NULL ) if ( (data = fopen(path, "r")) == NULL )
{ {
fgPrintf( FG_ASTRO, FG_ALERT, "Cannot open data file: '%s'\n", path); fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open data file: '%s'\n", path);
return; return;
} }
#ifdef DEBUG
fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path); fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
#endif
/* for all the objects... */ /* for all the objects... */
for (i = 0; i < 9; i ++) for (i = 0; i < 9; i ++)
@@ -164,20 +172,23 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
actTime = fgCalcActTime(t); actTime = fgCalcActTime(t);
/* calculate the actual orbital elements */ /* calculate the actual orbital elements */
planet->M = fgDegToRad(planet->MFirst + (planet->MSec * actTime)); // angle in radians planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime)); // angle in radians
planet->w = fgDegToRad(planet->wFirst + (planet->wSec * actTime)); // angle in radians planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime)); // angle in radians
planet->N = fgDegToRad(planet->NFirst + (planet->NSec * actTime)); // angle in radians planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime)); // angle in radians
planet->i = fgDegToRad(planet->iFirst + (planet->iSec * 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->e = planet->eFirst + (planet->eSec * actTime);
planet->a = planet->aFirst + (planet->aSec * actTime); planet->a = planet->aFirst + (planet->aSec * actTime);
} }
/* $Log$ /* $Log$
/* Revision 1.4 1998/01/27 00:47:47 curt /* Revision 1.5 1998/02/02 20:53:22 curt
/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message /* To version 0.29
/* system and commandline/config file processing code.
/* /*
* Revision 1.4 1998/01/27 00:47:47 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
*
* Revision 1.3 1998/01/22 02:59:27 curt * Revision 1.3 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H * Changed #ifdef FILE_H to #ifdef _FILE_H
* *
+6 -3
View File
@@ -68,7 +68,7 @@ struct CelestialCoord {
}; };
double fgDegToRad(double angle); /* double fgDegToRad(double angle); */
double fgCalcEccAnom(double M, double e); double fgCalcEccAnom(double M, double e);
double fgCalcActTime(struct fgTIME t); double fgCalcActTime(struct fgTIME t);
@@ -81,9 +81,12 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
/* $Log$ /* $Log$
/* Revision 1.3 1998/01/22 02:59:27 curt /* Revision 1.4 1998/02/02 20:53:22 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* To version 0.29
/* /*
* Revision 1.3 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
* Revision 1.2 1998/01/19 19:26:58 curt * Revision 1.2 1998/01/19 19:26:58 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously. * This should simplify things tremendously.
+78 -6
View File
@@ -23,12 +23,22 @@
**************************************************************************/ **************************************************************************/
#ifdef WIN32
# include <windows.h>
#endif
#include <GL/glut.h>
#include <XGL/xgl.h>
#include <Time/fg_time.h> #include <Time/fg_time.h>
#include <Astro/orbits.h> #include <Astro/orbits.h>
#include <Astro/planets.h> #include <Astro/planets.h>
#include <Astro/sun.h> #include <Astro/sun.h>
#include <Include/fg_constants.h>
#include <Main/fg_debug.h> #include <Main/fg_debug.h>
GLint planets = 0;
struct CelestialCoord fgCalculatePlanet(struct OrbElements planet, struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
struct OrbElements theSun, struct OrbElements theSun,
struct fgTIME t, int idx) struct fgTIME t, int idx)
@@ -45,8 +55,8 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
actTime = fgCalcActTime(t); actTime = fgCalcActTime(t);
/* calculate the angle between ecliptic and equatorial coordinate system */ /* calculate the angle between ecliptic and equatorial coordinate system */
ecl = fgDegToRad(23.4393 - 3.563E-7 * actTime); /* ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); */
ecl = 0.409093 - 6.2186E-9 * actTime;
/* calculate the eccentric anomaly */ /* calculate the eccentric anomaly */
eccAnom = fgCalcEccAnom(planet.M, planet.e); eccAnom = fgCalcEccAnom(planet.M, planet.e);
@@ -62,7 +72,7 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
yh = r * ( sin(planet.N) * cos(v+planet.w) + cos(planet.N) * sin(v+planet.w) * cos(planet.i)); yh = r * ( sin(planet.N) * cos(v+planet.w) + cos(planet.N) * sin(v+planet.w) * cos(planet.i));
zh = r * ( sin(v+planet.w) * sin(planet.i)); zh = r * ( sin(v+planet.w) * sin(planet.i));
/* calculate the ecleptic longitude and latitude */ /* calculate the ecliptic longitude and latitude */
/* /*
lonecl = atan2(yh, xh); lonecl = atan2(yh, xh);
@@ -133,12 +143,74 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
} }
void fgPlanetsInit( void )
{
int i;
struct CelestialCoord pltPos;
double magnitude;
/* if the display list was already built during a previous init,
recycle it */
if (planets)
xglDeleteLists(planets, 1);
planets = xglGenLists(1);
xglNewList( planets, GL_COMPILE );
xglBegin( GL_POINTS );
/* Add the planets to all four display lists */
for ( i = 2; i < 9; i++ ) {
fgSolarSystemUpdate(&(pltOrbElements[i]), cur_time_params);
pltPos = fgCalculatePlanet(pltOrbElements[i],
pltOrbElements[0], cur_time_params, i);
/* give the planets a temporary color, for testing purposes */
/* xglColor3f( 1.0, 0.0, 0.0); */
/* scale magnitudes to (0.0 - 1.0) */
magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
/* scale magnitudes again so they look ok */
/* magnitude =
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); */
/* the following statement could be made a little more sopisticated
for the moment: Stick to this one */
magnitude = magnitude * 0.7 + (3 * 0.1);
if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; }
xglColor3f(magnitude, magnitude, magnitude);
/* xglColor3f(1.0, 1.0,1.0); */
xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.Declination) );
}
xglEnd();
xglEndList();
}
void fgPlanetsRender( void ) {
xglCallList(planets);
}
/* $Log$ /* $Log$
/* Revision 1.3 1998/01/27 00:47:47 curt /* Revision 1.4 1998/02/02 20:53:23 curt
/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message /* To version 0.29
/* system and commandline/config file processing code.
/* /*
* Revision 1.3 1998/01/27 00:47:47 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
*
* Revision 1.2 1998/01/19 19:26:59 curt * Revision 1.2 1998/01/19 19:26:59 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously. * This should simplify things tremendously.
+10 -2
View File
@@ -31,13 +31,21 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
struct OrbElements theSun, struct OrbElements theSun,
struct fgTIME t, int idx); struct fgTIME t, int idx);
void fgPlanetsInit();
void fgPlanetsRender();
#endif /* PLANETS_H */ #endif /* PLANETS_H */
/* $Log$ /* $Log$
/* Revision 1.2 1998/01/22 02:59:28 curt /* Revision 1.3 1998/02/02 20:53:23 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H /* To version 0.29
/* /*
* Revision 1.2 1998/01/22 02:59:28 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
* Revision 1.1 1998/01/07 03:16:18 curt * Revision 1.1 1998/01/07 03:16:18 curt
* Moved from .../Src/Scenery/ to .../Src/Astro/ * Moved from .../Src/Scenery/ to .../Src/Astro/
* *
+11 -31
View File
@@ -59,14 +59,14 @@
void fgStarsInit( void ) { void fgStarsInit( void ) {
FILE *fd; FILE *fd;
struct fgGENERAL *g; struct fgGENERAL *g;
struct CelestialCoord pltPos; /* struct CelestialCoord pltPos; */
char path[1024]; char path[1024];
char line[256], name[256]; char line[256], name[256];
char *front, *end; char *front, *end;
double right_ascension, declination, magnitude; double right_ascension, declination, magnitude;
/* double ra_save, decl_save; */ /* double ra_save, decl_save; */
/* double ra_save1, decl_save1; */ /* double ra_save1, decl_save1; */
int count, i, j, max_stars; int count, i, max_stars;
fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n"); fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
@@ -81,10 +81,12 @@ void fgStarsInit( void ) {
max_stars = FG_MAX_STARS; max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) { for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
fgPrintf( FG_ASTRO, FG_INFO, " Loading %d Stars: %s\n", max_stars, path); fgPrintf( FG_ASTRO, FG_INFO,
" Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) { if ( (fd = fopen(path, "r")) == NULL ) {
fgPrintf( FG_ASTRO, FG_ALERT, "Cannot open star file: '%s'\n", path); fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open star file: '%s'\n", path);
return; return;
} }
@@ -166,31 +168,6 @@ void fgStarsInit( void ) {
fclose(fd); fclose(fd);
/* Add the planets to all four display lists */
for ( j = 2; j < 9; j++ ) {
pltPos = fgCalculatePlanet(pltOrbElements[j],
pltOrbElements[0], cur_time_params, j);
/* give the planets a temporary color, for testing purposes */
/* xglColor3f( 1.0, 0.0, 0.0); */
/* scale magnitudes to (0.0 - 1.0) */
magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
/* scale magnitudes again so they look ok */
if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; }
magnitude =
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
xglColor3f(magnitude, magnitude, magnitude);
xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.Declination) );
}
xglEnd(); xglEnd();
/* /*
@@ -276,9 +253,12 @@ void fgStarsRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.5 1998/01/27 18:35:53 curt /* Revision 1.6 1998/02/02 20:53:23 curt
/* Minor tweaks. /* To version 0.29
/* /*
* Revision 1.5 1998/01/27 18:35:53 curt
* Minor tweaks.
*
* Revision 1.4 1998/01/27 00:47:49 curt * Revision 1.4 1998/01/27 00:47:49 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code. * system and commandline/config file processing code.
+58 -53
View File
@@ -30,8 +30,9 @@
#include <Astro/orbits.h> #include <Astro/orbits.h>
#include <Astro/sun.h> #include <Astro/sun.h>
#include <Main/fg_debug.h> #include <Main/fg_debug.h>
#include <Include/fg_constants.h>
GLint sun_obj; GLint sun_obj = 0;
static struct CelestialCoord sunPos; static struct CelestialCoord sunPos;
@@ -77,7 +78,7 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
/* calculate the angle between ecliptic and equatorial coordinate system */ /* calculate the angle between ecliptic and equatorial coordinate system */
actTime = fgCalcActTime(t); actTime = fgCalcActTime(t);
ecl = fgDegToRad(23.4393 - 3.563E-7 * actTime); // Angle now in Rads ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); // Angle now in Rads
/* calculate the sun's ecliptic position */ /* calculate the sun's ecliptic position */
SolarPosition = fgCalcSunPos(params); SolarPosition = fgCalcSunPos(params);
@@ -96,47 +97,40 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
/* Initialize the Sun */ /* Initialize the Sun */
void fgSunInit( void ) { void fgSunInit( void ) {
static int dl_exists = 0; struct fgLIGHT *l;
struct fgTIME *t;
struct fgVIEW *v;
/* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
double x_2, x_4, x_8, x_10;
GLfloat ambient;
GLfloat amb[4];
l = &cur_light_params;
t = &cur_time_params;
v = &current_view;
fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n"); fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n");
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
#ifdef DEBUG
fgPrintf( FG_ASTRO, FG_INFO, fgPrintf( FG_ASTRO, FG_INFO,
"Sun found at %f (ra), %f (dec)\n", "Sun found at %f (ra), %f (dec)\n",
sunPos.RightAscension, sunPos.Declination); sunPos.RightAscension, sunPos.Declination);
#endif
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination); xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination); ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
zSun = 60000.0 * sin(sunPos.Declination); zSun = 60000.0 * sin(sunPos.Declination);
if ( !dl_exists ) {
dl_exists = 1;
/* printf("First time through, creating sun display list\n"); */ if (sun_obj) {
xglDeleteLists(sun_obj, 1);
sun_obj = xglGenLists(1);
xglNewList(sun_obj, GL_COMPILE );
glutSolidSphere(1.0, 10, 10);
xglEndList();
} }
}
/* printf("First time through, creating sun display list\n"); */
/* Draw the Sun */ sun_obj = xglGenLists(1);
void fgSunRender( void ) { xglNewList(sun_obj, GL_COMPILE );
struct fgVIEW *v;
struct fgTIME *t;
struct fgLIGHT *l;
/* GLfloat color[4] = { 0.85, 0.65, 0.05, 1.0 }; */
GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 };
double x_2, x_4, x_8, x_10;
GLfloat ambient;
GLfloat amb[3], diff[3];
t = &cur_time_params; t = &cur_time_params;
@@ -152,29 +146,29 @@ void fgSunRender( void ) {
if ( ambient < 0.3 ) ambient = 0.3; if ( ambient < 0.3 ) ambient = 0.3;
if ( ambient > 1.0 ) ambient = 1.0; if ( ambient > 1.0 ) ambient = 1.0;
amb[0] = 0.50 + ((ambient * 6.66) - 1.6); amb[0] = 0.00 + ((ambient * 6.0) - 1.0); /* minimum val = 0.8 */
amb[1] = 0.00 + ((ambient * 6.66) - 1.6); amb[1] = 0.00 + ((ambient * 11.0) - 3.0); /* minimum val = 0.3 */
amb[2] = 0.00 + ((ambient * 6.66) - 1.6); amb[2] = 0.00 + ((ambient * 12.0) - 3.6); /* minimum val = 0.0 */
amb[3] = 0.00; amb[3] = 1.00;
#ifdef DEBUG
fgPrintf( FG_ASTRO, FG_INFO,
"Color of the sun: %f, %f, %f\n"
"Ambient value : %f\n"
"Sun Angle : %f\n" , amb[0], amb[1], amb[2], ambient, t->sun_angle);
#endif
diff[0] = 0.0;
diff[1] = 0.0;
diff[2] = 0.0;
diff[3] = 1.0;
if (amb[0] > 1.0) amb[0] = 1.0;
if (amb[1] > 1.0) amb[1] = 1.0;
if (amb[2] > 1.0) amb[2] = 1.0;
fgPrintf( FG_ASTRO, FG_DEBUG,
"Color of the sun: %f, %f, %f\n"
"Ambient value : %f\n"
"Sun Angle : %f\n" ,
amb[0], amb[1], amb[2], ambient, l->sun_angle);
/* set lighting parameters */ /* set lighting parameters */
xglLightfv(GL_LIGHT0, GL_AMBIENT, color ); /*xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, color ); xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
xglMaterialfv(GL_FRONT, GL_AMBIENT, amb); xglMaterialfv(GL_FRONT, GL_AMBIENT, amb);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff); xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
xglMaterialfv(GL_FRONT, GL_SHININESS, diff); xglMaterialfv(GL_FRONT, GL_SHININESS, diff);
xglMaterialfv(GL_FRONT, GL_EMISSION, diff); xglMaterialfv(GL_FRONT, GL_EMISSION, diff);
xglMaterialfv(GL_FRONT, GL_SPECULAR, diff); xglMaterialfv(GL_FRONT, GL_SPECULAR, diff); */
/* xglDisable( GL_LIGHTING ); */ /* xglDisable( GL_LIGHTING ); */
@@ -182,21 +176,32 @@ void fgSunRender( void ) {
xglTranslatef(xSun, ySun, zSun); xglTranslatef(xSun, ySun, zSun);
xglScalef(1400, 1400, 1400); xglScalef(1400, 1400, 1400);
xglColor3f(0.85, 0.65, 0.05); /*xglColor3f(0.85, 0.65, 0.05);*/
xglColor3f(amb[0], amb[1], amb[2]);
xglCallList(sun_obj); glutSolidSphere(1.0, 10, 10);
xglPopMatrix(); xglPopMatrix();
/* xglEnable( GL_LIGHTING ); */ /* xglEnable( GL_LIGHTING ); */
xglEndList();
}
/* Draw the Sun */
void fgSunRender( void ) {
xglCallList(sun_obj);
} }
/* $Log$ /* $Log$
/* Revision 1.4 1998/01/27 00:47:50 curt /* Revision 1.5 1998/02/02 20:53:24 curt
/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message /* To version 0.29
/* system and commandline/config file processing code.
/* /*
* Revision 1.4 1998/01/27 00:47:50 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.
*
* Revision 1.3 1998/01/19 19:27:00 curt * Revision 1.3 1998/01/19 19:27:00 curt
* Merged in make system changes from Bob Kuehne <rpk@sgi.com> * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
* This should simplify things tremendously. * This should simplify things tremendously.