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:
+36
-50
@@ -38,7 +38,7 @@
|
|||||||
struct CelestialCoord moonPos;
|
struct CelestialCoord moonPos;
|
||||||
|
|
||||||
static float xMoon, yMoon, zMoon;
|
static float xMoon, yMoon, zMoon;
|
||||||
static GLint moon;
|
static GLint moon = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -67,8 +67,8 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
|||||||
/* calculate the angle between ecliptic and equatorial coordinate
|
/* calculate the angle between ecliptic and equatorial coordinate
|
||||||
* system, in Radians */
|
* system, in Radians */
|
||||||
actTime = fgCalcActTime(t);
|
actTime = fgCalcActTime(t);
|
||||||
/* ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);*/
|
ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
|
||||||
ecl = 0.409093 - 6.2186E-9 * 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);
|
||||||
@@ -80,8 +80,10 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
|||||||
r = sqrt(xv*xv + yv*yv);
|
r = sqrt(xv*xv + yv*yv);
|
||||||
|
|
||||||
/* estimate the geocentric rectangular coordinates here */
|
/* estimate the geocentric rectangular coordinates here */
|
||||||
xh = r * (cos(params.N) * cos(v + params.w) - sin(params.N) * sin(v + params.w) * cos(params.i));
|
xh = r * (cos (params.N) * cos (v + params.w) -
|
||||||
yh = r * (sin(params.N) * cos(v + params.w) + cos(params.N) * sin(v + params.w) * cos(params.i));
|
sin (params.N) * sin (v + params.w) * cos (params.i));
|
||||||
|
yh = r * (sin (params.N) * cos (v + params.w) +
|
||||||
|
cos (params.N) * sin (v + params.w) * cos (params.i));
|
||||||
zh = r * (sin(v + params.w) * sin(params.i));
|
zh = r * (sin(v + params.w) * sin(params.i));
|
||||||
|
|
||||||
/* calculate the ecliptic latitude and longitude here */
|
/* calculate the ecliptic latitude and longitude here */
|
||||||
@@ -90,7 +92,7 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
|||||||
|
|
||||||
/* calculate a number of perturbations, i.e. disturbances caused by
|
/* calculate a number of perturbations, i.e. disturbances caused by
|
||||||
* the gravitational influence of the sun and the other mayor
|
* the gravitational influence of the sun and the other mayor
|
||||||
* planets, the largest even have their own names */
|
* planets. The largest of these 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;
|
||||||
@@ -155,24 +157,19 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
topocCoord.RightAscension = geocCoord.RightAscension - mpar * rho * cos(gclat) * sin(HA) / cos(geocCoord.Declination);
|
topocCoord.RightAscension = geocCoord.RightAscension -
|
||||||
topocCoord.Declination = geocCoord.Declination - mpar * rho * sin(gclat) * sin(g - geocCoord.Declination) / sin(g);
|
mpar * rho * cos (gclat) * sin (HA) / cos (geocCoord.Declination);
|
||||||
|
topocCoord.Declination = geocCoord.Declination -
|
||||||
|
mpar * rho * sin (gclat) * sin (g - geocCoord.Declination) / sin (g);
|
||||||
return topocCoord;
|
return topocCoord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fgMoonInit( void ) {
|
void fgMoonInit( void ) {
|
||||||
/* struct fgLIGHT *l; */
|
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.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 };
|
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; */
|
|
||||||
|
|
||||||
/* 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);
|
||||||
@@ -184,52 +181,41 @@ void fgMoonInit( void ) {
|
|||||||
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
zMoon = 60000.0 * sin(moonPos.Declination);
|
zMoon = 60000.0 * sin(moonPos.Declination);
|
||||||
|
|
||||||
if ( !dl_exists ) {
|
if (moon) {
|
||||||
dl_exists = 1;
|
xglDeleteLists (moon, 1);
|
||||||
|
|
||||||
/* printf("First time through, creating moon display list\n"); */
|
|
||||||
|
|
||||||
moon = xglGenLists(1);
|
|
||||||
xglNewList(moon, GL_COMPILE );
|
|
||||||
|
|
||||||
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
|
|
||||||
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
|
|
||||||
|
|
||||||
glutSolidSphere(1.0, 10, 10);
|
|
||||||
|
|
||||||
xglEndList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moon = xglGenLists (1);
|
||||||
|
xglNewList (moon, GL_COMPILE);
|
||||||
|
|
||||||
|
xglMaterialfv (GL_FRONT, GL_AMBIENT, black);
|
||||||
|
xglMaterialfv (GL_FRONT, GL_DIFFUSE, moonColor);
|
||||||
|
xglPushMatrix ();
|
||||||
|
xglTranslatef (xMoon, yMoon, zMoon);
|
||||||
|
xglScalef (1400, 1400, 1400);
|
||||||
|
|
||||||
|
glutSolidSphere (1.0, 10, 10);
|
||||||
|
xglPopMatrix ();
|
||||||
|
xglEndList ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Draw the moon */
|
/* Draw the moon */
|
||||||
void fgMoonRender( void ) {
|
void fgMoonRender( void ) {
|
||||||
/* struct fgLIGHT *l; */
|
|
||||||
|
|
||||||
/* printf("Rendering moon\n"); */
|
|
||||||
|
|
||||||
/* l = &cur_light_params; */
|
|
||||||
|
|
||||||
/* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->sky_color ); */
|
|
||||||
/* xglMaterialfv(GL_FRONT, GL_DIFFUSE, white); */
|
|
||||||
|
|
||||||
xglPushMatrix();
|
|
||||||
xglTranslatef(xMoon, yMoon, zMoon);
|
|
||||||
xglScalef(1400, 1400, 1400);
|
|
||||||
|
|
||||||
xglCallList(moon);
|
xglCallList(moon);
|
||||||
|
|
||||||
xglPopMatrix();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.6 1998/02/07 15:29:32 curt
|
/* Revision 1.7 1998/02/23 19:07:54 curt
|
||||||
/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
|
||||||
/* <chotchkiss@namg.us.anritsu.com>
|
/* calculation code between sun display, and other FG sections that use this
|
||||||
|
/* for things like lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.6 1998/02/07 15:29:32 curt
|
||||||
|
* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
||||||
|
* <chotchkiss@namg.us.anritsu.com>
|
||||||
|
*
|
||||||
* Revision 1.5 1998/02/02 20:53:21 curt
|
* Revision 1.5 1998/02/02 20:53:21 curt
|
||||||
* To version 0.29
|
* To version 0.29
|
||||||
*
|
*
|
||||||
|
|||||||
+8
-6
@@ -31,11 +31,8 @@
|
|||||||
#include <Time/fg_time.h>
|
#include <Time/fg_time.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/* #define X .525731112119133606 */
|
|
||||||
/* #define Z .850650808352039932 */
|
|
||||||
|
|
||||||
|
/* Initialize the Moon Display management Subsystem */
|
||||||
/* Initialize the Moon Display management Subsystem */
|
|
||||||
void fgMoonInit( void );
|
void fgMoonInit( void );
|
||||||
|
|
||||||
/* Draw the Moon */
|
/* Draw the Moon */
|
||||||
@@ -51,9 +48,14 @@ extern struct OrbElements pltOrbElements[9];
|
|||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.5 1998/02/02 20:53:21 curt
|
/* Revision 1.6 1998/02/23 19:07:54 curt
|
||||||
/* To version 0.29
|
/* 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.5 1998/02/02 20:53:21 curt
|
||||||
|
* To version 0.29
|
||||||
|
*
|
||||||
* Revision 1.4 1998/01/22 02:59:27 curt
|
* Revision 1.4 1998/01/22 02:59:27 curt
|
||||||
* Changed #ifdef FILE_H to #ifdef _FILE_H
|
* Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||||
*
|
*
|
||||||
|
|||||||
+32
-49
@@ -36,48 +36,12 @@
|
|||||||
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)
|
||||||
{
|
{
|
||||||
return (t.mjd - 36523.5);
|
return (t.mjd - 36523.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* convert degrees to radians */
|
|
||||||
/*
|
|
||||||
double fgDegToRad(double angle)
|
|
||||||
{
|
|
||||||
return (angle * PIOVER180);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
double fgCalcEccAnom(double M, double e)
|
double fgCalcEccAnom(double M, double e)
|
||||||
{
|
{
|
||||||
double
|
double
|
||||||
@@ -101,16 +65,26 @@ double fgCalcEccAnom(double M, double e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function assumes that if the FILE ptr is valid that the contents
|
/* This function assumes that if the FILE ptr is valid that the
|
||||||
// will be valid. Should we check the file for validity?
|
contents will be valid. Should we check the file for validity? */
|
||||||
|
|
||||||
void fgReadOrbElements(struct OrbElements *dest, FILE *src)
|
/* 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) */
|
||||||
|
|
||||||
|
int fgReadOrbElements(struct OrbElements *dest, FILE *src)
|
||||||
{
|
{
|
||||||
char line[256];
|
char line[256];
|
||||||
int i,j;
|
int i,j;
|
||||||
j = 0;
|
j = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (feof (src)) {
|
||||||
|
fgPrintf (FG_ASTRO, FG_ALERT,
|
||||||
|
"End of file found while reading planetary positions:\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
fgets(line, 256,src);
|
fgets(line, 256,src);
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
@@ -127,6 +101,8 @@ void fgReadOrbElements(struct OrbElements *dest, FILE *src)
|
|||||||
&dest->aFirst, &dest->aSec,
|
&dest->aFirst, &dest->aSec,
|
||||||
&dest->eFirst, &dest->eSec,
|
&dest->eFirst, &dest->eSec,
|
||||||
&dest->MFirst, &dest->MSec);
|
&dest->MFirst, &dest->MSec);
|
||||||
|
|
||||||
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -159,7 +135,9 @@ int fgSolarSystemInit(struct fgTIME t)
|
|||||||
for (i = 0; i < 9; i ++)
|
for (i = 0; i < 9; i ++)
|
||||||
{
|
{
|
||||||
/* ...read from the data file ... */
|
/* ...read from the data file ... */
|
||||||
fgReadOrbElements(&pltOrbElements[i], data);
|
if (!(fgReadOrbElements (&pltOrbElements[i], data))) {
|
||||||
|
ret_val = 0;
|
||||||
|
}
|
||||||
/* ...and calculate the actual values */
|
/* ...and calculate the actual values */
|
||||||
fgSolarSystemUpdate(&pltOrbElements[i], t);
|
fgSolarSystemUpdate(&pltOrbElements[i], t);
|
||||||
}
|
}
|
||||||
@@ -177,20 +155,25 @@ 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 = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime)); // angle in radians
|
planet->M = DEG_TO_RAD * (planet->MFirst + (planet->MSec * actTime));
|
||||||
planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime)); // angle in radians
|
planet->w = DEG_TO_RAD * (planet->wFirst + (planet->wSec * actTime));
|
||||||
planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime)); // angle in radians
|
planet->N = DEG_TO_RAD * (planet->NFirst + (planet->NSec * actTime));
|
||||||
planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime)); // angle in radians
|
planet->i = DEG_TO_RAD * (planet->iFirst + (planet->iSec * actTime));
|
||||||
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.7 1998/02/12 21:59:33 curt
|
/* Revision 1.8 1998/02/23 19:07:55 curt
|
||||||
/* Incorporated code changes contributed by Charlie Hotchkiss
|
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
|
||||||
/* <chotchkiss@namg.us.anritsu.com>
|
/* 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
|
* Revision 1.6 1998/02/03 23:20:11 curt
|
||||||
* Lots of little tweaks to fix various consistency problems discovered by
|
* 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
|
* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
|
||||||
|
|||||||
+16
-9
@@ -34,14 +34,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define STANDARDEPOCH 2000
|
//#define STANDARDEPOCH 2000
|
||||||
#define PIOVER180 1.74532925199433E-002
|
|
||||||
|
|
||||||
struct SunPos {
|
typedef struct {
|
||||||
double xs;
|
double xs;
|
||||||
double ys;
|
double ys;
|
||||||
double dist;
|
double dist;
|
||||||
};
|
double lonSun;
|
||||||
|
} fgSUNPOS;
|
||||||
|
|
||||||
|
extern fgSUNPOS solarPosition;
|
||||||
|
|
||||||
|
|
||||||
struct OrbElements {
|
struct OrbElements {
|
||||||
double NFirst; /* longitude of the ascending node first part */
|
double NFirst; /* longitude of the ascending node first part */
|
||||||
@@ -68,11 +71,10 @@ struct CelestialCoord {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 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);
|
||||||
|
|
||||||
void fgReadOrbElements(struct OrbElements *dest, FILE *src);
|
int fgReadOrbElements (struct OrbElements *dest, FILE * src);
|
||||||
int fgSolarSystemInit(struct fgTIME t);
|
int fgSolarSystemInit(struct fgTIME t);
|
||||||
void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
|
void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
|
||||||
|
|
||||||
@@ -81,10 +83,15 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
|
|||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.5 1998/02/12 21:59:35 curt
|
/* Revision 1.6 1998/02/23 19:07:55 curt
|
||||||
/* Incorporated code changes contributed by Charlie Hotchkiss
|
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
|
||||||
/* <chotchkiss@namg.us.anritsu.com>
|
/* calculation code between sun display, and other FG sections that use this
|
||||||
|
/* for things like lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.5 1998/02/12 21:59:35 curt
|
||||||
|
* Incorporated code changes contributed by Charlie Hotchkiss
|
||||||
|
* <chotchkiss@namg.us.anritsu.com>
|
||||||
|
*
|
||||||
* Revision 1.4 1998/02/02 20:53:22 curt
|
* Revision 1.4 1998/02/02 20:53:22 curt
|
||||||
* To version 0.29
|
* To version 0.29
|
||||||
*
|
*
|
||||||
|
|||||||
+45
-40
@@ -43,23 +43,19 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||||||
struct OrbElements theSun,
|
struct OrbElements theSun,
|
||||||
struct fgTIME t, int idx)
|
struct fgTIME t, int idx)
|
||||||
{
|
{
|
||||||
struct CelestialCoord
|
struct CelestialCoord result;
|
||||||
result;
|
|
||||||
|
|
||||||
struct SunPos
|
fgSUNPOS SolarPosition;
|
||||||
SolarPosition;
|
|
||||||
|
|
||||||
double
|
double eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
|
||||||
eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
|
|
||||||
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
|
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
|
||||||
|
|
||||||
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 = DEG_TO_RAD * (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);
|
||||||
|
|
||||||
/* calculate the planets distance (r) and true anomaly (v) */
|
/* calculate the planets distance (r) and true anomaly (v) */
|
||||||
xv = planet.a * (cos(eccAnom) - planet.e);
|
xv = planet.a * (cos(eccAnom) - planet.e);
|
||||||
@@ -68,21 +64,16 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||||||
r = sqrt ( xv*xv + yv*yv);
|
r = sqrt ( xv*xv + yv*yv);
|
||||||
|
|
||||||
/* calculate the planets position in 3-dimensional space */
|
/* calculate the planets position in 3-dimensional space */
|
||||||
xh = r * ( cos(planet.N) * cos(v+planet.w) - sin(planet.N) * sin(v+planet.w) * cos(planet.i));
|
xh = r * (cos (planet.N) * cos (v + planet.w) -
|
||||||
yh = r * ( sin(planet.N) * cos(v+planet.w) + cos(planet.N) * sin(v+planet.w) * cos(planet.i));
|
sin (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 ecliptic longitude and latitude */
|
/* calculate the ecliptic longitude and latitude */
|
||||||
|
|
||||||
/*
|
xg = xh + solarPosition.xs;
|
||||||
lonecl = atan2(yh, xh);
|
yg = yh + solarPosition.ys;
|
||||||
latecl = atan2(zh, sqrt ( xh*xh + yh*yh));
|
|
||||||
*/
|
|
||||||
/* calculate the solar position */
|
|
||||||
|
|
||||||
SolarPosition = fgCalcSunPos(theSun);
|
|
||||||
xg = xh + SolarPosition.xs;
|
|
||||||
yg = yh + SolarPosition.ys;
|
|
||||||
zg = zh;
|
zg = zh;
|
||||||
|
|
||||||
xe = xg;
|
xe = xg;
|
||||||
@@ -92,7 +83,6 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||||||
result.RightAscension = atan2(ye,xe);
|
result.RightAscension = atan2(ye,xe);
|
||||||
result.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
|
result.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
|
||||||
|
|
||||||
|
|
||||||
/* Let's calculate the brightness of the planet */
|
/* Let's calculate the brightness of the planet */
|
||||||
R = sqrt ( xg*xg + yg*yg + zg*zg);
|
R = sqrt ( xg*xg + yg*yg + zg*zg);
|
||||||
s = SolarPosition.dist;
|
s = SolarPosition.dist;
|
||||||
@@ -117,7 +107,9 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||||||
ir = 0.4897394;
|
ir = 0.4897394;
|
||||||
Nr = 2.9585076 + 6.6672E-7*actTime;
|
Nr = 2.9585076 + 6.6672E-7*actTime;
|
||||||
|
|
||||||
B = asin ( sin (result.Declination) * cos(ir) - cos(result.Declination) * sin (ir) * sin (result.RightAscension - Nr));
|
B = asin (sin (result.Declination) * cos (ir) -
|
||||||
|
cos (result.Declination) * sin (ir) *
|
||||||
|
sin (result.RightAscension - Nr));
|
||||||
ring_magn = -2.6 * sin (fabs(B)) + 1.2 * pow(sin(B),2);
|
ring_magn = -2.6 * sin (fabs(B)) + 1.2 * pow(sin(B),2);
|
||||||
result.magnitude = -9.0 + 5*log10( r*R ) + 0.044 * FV + ring_magn;
|
result.magnitude = -9.0 + 5*log10( r*R ) + 0.044 * FV + ring_magn;
|
||||||
break;
|
break;
|
||||||
@@ -145,15 +137,18 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||||||
|
|
||||||
void fgPlanetsInit( void )
|
void fgPlanetsInit( void )
|
||||||
{
|
{
|
||||||
|
struct fgLIGHT *l;
|
||||||
int i;
|
int i;
|
||||||
struct CelestialCoord pltPos;
|
struct CelestialCoord pltPos;
|
||||||
double magnitude;
|
double magnitude;
|
||||||
|
|
||||||
|
l = &cur_light_params;
|
||||||
/* if the display list was already built during a previous init,
|
/* if the display list was already built during a previous init,
|
||||||
recycle it */
|
then recycle it */
|
||||||
|
|
||||||
if (planets)
|
if (planets) {
|
||||||
xglDeleteLists(planets, 1);
|
xglDeleteLists(planets, 1);
|
||||||
|
}
|
||||||
|
|
||||||
planets = xglGenLists(1);
|
planets = xglGenLists(1);
|
||||||
xglNewList( planets, GL_COMPILE );
|
xglNewList( planets, GL_COMPILE );
|
||||||
@@ -166,10 +161,6 @@ void fgPlanetsInit( void )
|
|||||||
pltPos = fgCalculatePlanet(pltOrbElements[i],
|
pltPos = fgCalculatePlanet(pltOrbElements[i],
|
||||||
pltOrbElements[0], cur_time_params, 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;
|
magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
|
||||||
|
|
||||||
/* scale magnitudes again so they look ok */
|
/* scale magnitudes again so they look ok */
|
||||||
@@ -182,15 +173,24 @@ void fgPlanetsInit( void )
|
|||||||
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
if ( magnitude > 1.0 ) { magnitude = 1.0; }
|
||||||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||||
|
|
||||||
|
/* Add planets to the display list, based on sun_angle and current
|
||||||
|
magnitude It's pretty experimental... */
|
||||||
|
|
||||||
xglColor3f(magnitude, magnitude, magnitude);
|
if ((double) (l->sun_angle - FG_PI_2) >
|
||||||
/* xglColor3f(1.0, 1.0,1.0); */
|
((magnitude - 1.0) * -20 * DEG_TO_RAD))
|
||||||
|
{
|
||||||
|
xglColor3f (magnitude, magnitude, magnitude);
|
||||||
|
printf ("Sun Angle to Horizon (in Rads) = %f\n",
|
||||||
|
(double) (l->sun_angle - FG_PI_2));
|
||||||
|
printf ("Transformed Magnitude is :%f %f\n",
|
||||||
|
magnitude, (magnitude - 1.0) * -20 * DEG_TO_RAD);
|
||||||
|
|
||||||
xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
|
xglVertex3f (50000.0 * cos (pltPos.RightAscension) *
|
||||||
cos(pltPos.Declination),
|
cos (pltPos.Declination),
|
||||||
50000.0 * sin(pltPos.RightAscension) *
|
50000.0 * sin (pltPos.RightAscension) *
|
||||||
cos(pltPos.Declination),
|
cos (pltPos.Declination),
|
||||||
50000.0 * sin(pltPos.Declination) );
|
50000.0 * sin (pltPos.Declination));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xglEnd();
|
xglEnd();
|
||||||
xglEndList();
|
xglEndList();
|
||||||
@@ -204,10 +204,15 @@ void fgPlanetsRender( void ) {
|
|||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.6 1998/02/12 21:59:36 curt
|
/* Revision 1.7 1998/02/23 19:07:55 curt
|
||||||
/* Incorporated code changes contributed by Charlie Hotchkiss
|
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
|
||||||
/* <chotchkiss@namg.us.anritsu.com>
|
/* calculation code between sun display, and other FG sections that use this
|
||||||
|
/* for things like lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.6 1998/02/12 21:59:36 curt
|
||||||
|
* Incorporated code changes contributed by Charlie Hotchkiss
|
||||||
|
* <chotchkiss@namg.us.anritsu.com>
|
||||||
|
*
|
||||||
* Revision 1.5 1998/02/03 23:20:12 curt
|
* Revision 1.5 1998/02/03 23:20:12 curt
|
||||||
* Lots of little tweaks to fix various consistency problems discovered by
|
* 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
|
* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
|
||||||
|
|||||||
+35
-50
@@ -25,26 +25,23 @@
|
|||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
#include <XGL/xgl.h>
|
#include <XGL/xgl.h>
|
||||||
|
|
||||||
#include <Time/fg_time.h>
|
|
||||||
#include <Main/views.h>
|
|
||||||
#include <Astro/orbits.h>
|
#include <Astro/orbits.h>
|
||||||
#include <Astro/sun.h>
|
#include <Astro/sun.h>
|
||||||
#include <Main/fg_debug.h>
|
|
||||||
#include <Include/fg_constants.h>
|
#include <Include/fg_constants.h>
|
||||||
|
#include <Main/fg_debug.h>
|
||||||
|
#include <Main/views.h>
|
||||||
|
#include <Time/fg_time.h>
|
||||||
|
#include <Time/sunpos.h>
|
||||||
|
|
||||||
GLint sun_obj = 0;
|
GLint sun_obj = 0;
|
||||||
|
|
||||||
static struct CelestialCoord sunPos;
|
static struct CelestialCoord sunPos;
|
||||||
|
|
||||||
float xSun, ySun, zSun;
|
fgSUNPOS solarPosition;
|
||||||
|
|
||||||
struct SunPos fgCalcSunPos(struct OrbElements params)
|
void fgCalcSunPos(struct OrbElements params)
|
||||||
{
|
{
|
||||||
double
|
double EccAnom, xv, yv, v, r;
|
||||||
EccAnom, lonSun,
|
|
||||||
xv, yv, v, r;
|
|
||||||
struct SunPos
|
|
||||||
solarPosition;
|
|
||||||
|
|
||||||
/* calculate the eccentric anomaly */
|
/* calculate the eccentric anomaly */
|
||||||
EccAnom = fgCalcEccAnom(params.M, params.e);
|
EccAnom = fgCalcEccAnom(params.M, params.e);
|
||||||
@@ -56,37 +53,31 @@ struct SunPos fgCalcSunPos(struct OrbElements params)
|
|||||||
r = sqrt(xv*xv + yv*yv);
|
r = sqrt(xv*xv + yv*yv);
|
||||||
|
|
||||||
/* calculate the the Sun's true longitude (lonsun) */
|
/* calculate the the Sun's true longitude (lonsun) */
|
||||||
lonSun = v + params.w;
|
solarPosition.lonSun = v + params.w;
|
||||||
|
|
||||||
/* convert true longitude and distance to ecliptic rectangular geocentric
|
/* convert true longitude and distance to ecliptic rectangular
|
||||||
coordinates (xs, ys) */
|
geocentric coordinates (xs, ys) */
|
||||||
solarPosition.xs = r * cos(lonSun);
|
solarPosition.xs = r * cos (solarPosition.lonSun);
|
||||||
solarPosition.ys = r * sin(lonSun);
|
solarPosition.ys = r * sin (solarPosition.lonSun);
|
||||||
solarPosition.dist = r;
|
solarPosition.dist = r;
|
||||||
return solarPosition;
|
/* return solarPosition; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
|
struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
|
||||||
{
|
{
|
||||||
struct CelestialCoord
|
struct CelestialCoord result;
|
||||||
result;
|
double xe, ye, ze, ecl, actTime;
|
||||||
struct SunPos
|
|
||||||
SolarPosition;
|
|
||||||
double
|
|
||||||
xe, ye, ze, ecl, actTime;
|
|
||||||
|
|
||||||
/* 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 = DEG_TO_RAD * (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 */
|
/* convert ecliptic coordinates to equatorial rectangular
|
||||||
SolarPosition = fgCalcSunPos(params);
|
geocentric coordinates */
|
||||||
|
xe = solarPosition.xs;
|
||||||
/* convert ecliptic coordinates to equatorial rectangular geocentric coordinates */
|
ye = solarPosition.ys * cos (ecl);
|
||||||
xe = SolarPosition.xs;
|
ze = solarPosition.ys * sin (ecl);
|
||||||
ye = SolarPosition.ys * cos(ecl);
|
|
||||||
ze = SolarPosition.ys * sin(ecl);
|
|
||||||
|
|
||||||
/* and finally... Calulate Right Ascention and Declination */
|
/* and finally... Calulate Right Ascention and Declination */
|
||||||
result.RightAscension = atan2( ye, xe);
|
result.RightAscension = atan2( ye, xe);
|
||||||
@@ -100,6 +91,7 @@ void fgSunInit( void ) {
|
|||||||
struct fgLIGHT *l;
|
struct fgLIGHT *l;
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
struct fgVIEW *v;
|
struct fgVIEW *v;
|
||||||
|
float xSun, ySun, zSun;
|
||||||
|
|
||||||
/* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
|
/* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
|
||||||
double x_2, x_4, x_8, x_10;
|
double x_2, x_4, x_8, x_10;
|
||||||
@@ -112,9 +104,14 @@ void fgSunInit( void ) {
|
|||||||
|
|
||||||
fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n");
|
fgPrintf( FG_ASTRO, FG_INFO, " Initializing the Sun\n");
|
||||||
|
|
||||||
|
// Calculate basic sun position
|
||||||
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);
|
||||||
|
|
||||||
|
// Calculate additional sun position parameters based on the above
|
||||||
|
// position that are needed by other parts of FG
|
||||||
|
fgUpdateSunPos();
|
||||||
|
|
||||||
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);
|
||||||
@@ -162,29 +159,12 @@ void fgSunInit( void ) {
|
|||||||
"Sun Angle : %f\n" ,
|
"Sun Angle : %f\n" ,
|
||||||
amb[0], amb[1], amb[2], ambient, l->sun_angle);
|
amb[0], amb[1], amb[2], ambient, l->sun_angle);
|
||||||
|
|
||||||
/* set lighting parameters */
|
|
||||||
/*xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
|
|
||||||
xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
|
|
||||||
xglMaterialfv(GL_FRONT, GL_AMBIENT, amb);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_SHININESS, diff);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_EMISSION, diff);
|
|
||||||
xglMaterialfv(GL_FRONT, GL_SPECULAR, diff); */
|
|
||||||
|
|
||||||
/* xglDisable( GL_LIGHTING ); */
|
|
||||||
|
|
||||||
xglPushMatrix();
|
xglPushMatrix();
|
||||||
xglTranslatef(xSun, ySun, zSun);
|
xglTranslatef(xSun, ySun, zSun);
|
||||||
xglScalef(1400, 1400, 1400);
|
xglScalef(1400, 1400, 1400);
|
||||||
|
|
||||||
/*xglColor3f(0.85, 0.65, 0.05);*/
|
|
||||||
xglColor3f(amb[0], amb[1], amb[2]);
|
xglColor3f(amb[0], amb[1], amb[2]);
|
||||||
glutSolidSphere(1.0, 10, 10);
|
glutSolidSphere(1.0, 10, 10);
|
||||||
|
|
||||||
xglPopMatrix();
|
xglPopMatrix();
|
||||||
|
|
||||||
/* xglEnable( GL_LIGHTING ); */
|
|
||||||
|
|
||||||
xglEndList();
|
xglEndList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,10 +176,15 @@ void fgSunRender( void ) {
|
|||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.6 1998/02/12 21:59:39 curt
|
/* Revision 1.7 1998/02/23 19:07:56 curt
|
||||||
/* Incorporated code changes contributed by Charlie Hotchkiss
|
/* Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
|
||||||
/* <chotchkiss@namg.us.anritsu.com>
|
/* calculation code between sun display, and other FG sections that use this
|
||||||
|
/* for things like lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.6 1998/02/12 21:59:39 curt
|
||||||
|
* Incorporated code changes contributed by Charlie Hotchkiss
|
||||||
|
* <chotchkiss@namg.us.anritsu.com>
|
||||||
|
*
|
||||||
* Revision 1.5 1998/02/02 20:53:24 curt
|
* Revision 1.5 1998/02/02 20:53:24 curt
|
||||||
* To version 0.29
|
* To version 0.29
|
||||||
*
|
*
|
||||||
|
|||||||
+11
-3
@@ -27,7 +27,10 @@
|
|||||||
#define _SUN_H
|
#define _SUN_H
|
||||||
|
|
||||||
|
|
||||||
struct SunPos fgCalcSunPos(struct OrbElements sunParams);
|
extern struct fgSUNPOS solarPosition;
|
||||||
|
|
||||||
|
|
||||||
|
void fgCalcSunPos (struct OrbElements sunParams);
|
||||||
extern struct OrbElements pltOrbElements[9];
|
extern struct OrbElements pltOrbElements[9];
|
||||||
|
|
||||||
/* Initialize the Sun */
|
/* Initialize the Sun */
|
||||||
@@ -41,9 +44,14 @@ void fgSunRender( void );
|
|||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.3 1998/01/22 02:59:29 curt
|
/* Revision 1.4 1998/02/23 19:07:57 curt
|
||||||
/* Changed #ifdef FILE_H to #ifdef _FILE_H
|
/* 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.3 1998/01/22 02:59:29 curt
|
||||||
|
* Changed #ifdef FILE_H to #ifdef _FILE_H
|
||||||
|
*
|
||||||
* Revision 1.2 1998/01/19 18:40:19 curt
|
* Revision 1.2 1998/01/19 18:40:19 curt
|
||||||
* Tons of little changes to clean up the code and to remove fatal errors
|
* Tons of little changes to clean up the code and to remove fatal errors
|
||||||
* when building with the c++ compiler.
|
* when building with the c++ compiler.
|
||||||
|
|||||||
Reference in New Issue
Block a user