1
0
Fork 0

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 1998-02-23 19:07:49 +00:00
parent 1f0a7128bd
commit e798c59696
12 changed files with 258 additions and 242 deletions

View file

@ -38,7 +38,7 @@
struct CelestialCoord moonPos;
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
* system, in Radians */
actTime = fgCalcActTime(t);
/* ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);*/
ecl = 0.409093 - 6.2186E-9 * actTime;
ecl = ((DEG_TO_RAD * 23.4393) - (DEG_TO_RAD * 3.563E-7) * actTime);
/*ecl = 0.409093 - 6.2186E-9 * actTime; */
/* calculate the eccentric anomaly */
eccAnom = fgCalcEccAnom(params.M, params.e);
@ -80,8 +80,10 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
r = sqrt(xv*xv + yv*yv);
/* 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));
yh = r * (sin(params.N) * cos(v + params.w) + cos(params.N) * sin(v + params.w) * cos(params.i));
xh = r * (cos (params.N) * cos (v + params.w) -
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));
/* 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
* 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;
Lm = params.M + params.w + params.N;
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.Declination = geocCoord.Declination - mpar * rho * sin(gclat) * sin(g - geocCoord.Declination) / sin(g);
topocCoord.RightAscension = geocCoord.RightAscension -
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;
}
void fgMoonInit( void ) {
/* struct fgLIGHT *l; */
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 moonColor[4] = {0.85, 0.75, 0.35, 1.0};
GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
fgPrintf( FG_ASTRO, FG_INFO, "Initializing the Moon\n");
/* l = &cur_light_params; */
/* position the moon */
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
cur_time_params);
@ -184,52 +181,41 @@ void fgMoonInit( void ) {
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
zMoon = 60000.0 * sin(moonPos.Declination);
if ( !dl_exists ) {
dl_exists = 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();
if (moon) {
xglDeleteLists (moon, 1);
}
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 */
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);
xglPopMatrix();
}
/* $Log$
/* 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.7 1998/02/23 19:07:54 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.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
* To version 0.29
*

View file

@ -31,11 +31,8 @@
#include <Time/fg_time.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 );
/* Draw the Moon */
@ -51,9 +48,14 @@ extern struct OrbElements pltOrbElements[9];
/* $Log$
/* Revision 1.5 1998/02/02 20:53:21 curt
/* To version 0.29
/* Revision 1.6 1998/02/23 19:07:54 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.5 1998/02/02 20:53:21 curt
* To version 0.29
*
* Revision 1.4 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*

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

View file

@ -34,14 +34,17 @@
#define STANDARDEPOCH 2000
#define PIOVER180 1.74532925199433E-002
//#define STANDARDEPOCH 2000
struct SunPos {
typedef struct {
double xs;
double ys;
double dist;
};
double lonSun;
} fgSUNPOS;
extern fgSUNPOS solarPosition;
struct OrbElements {
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 fgCalcActTime(struct fgTIME t);
void fgReadOrbElements(struct OrbElements *dest, FILE *src);
int fgReadOrbElements (struct OrbElements *dest, FILE * src);
int fgSolarSystemInit(struct fgTIME t);
void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
@ -81,10 +83,15 @@ void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
/* $Log$
/* Revision 1.5 1998/02/12 21:59:35 curt
/* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* Revision 1.6 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.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
* To version 0.29
*

View file

@ -43,46 +43,37 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
struct OrbElements theSun,
struct fgTIME t, int idx)
{
struct CelestialCoord
result;
struct CelestialCoord result;
struct SunPos
SolarPosition;
fgSUNPOS SolarPosition;
double
eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
double eccAnom, r, v, ecl, actTime, R, s, ir, Nr, B, FV, ring_magn,
xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze;
actTime = fgCalcActTime(t);
/* calculate the angle between ecliptic and equatorial coordinate system */
/* ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime); */
ecl = 0.409093 - 6.2186E-9 * actTime;
actTime = fgCalcActTime(t);
/*calculate the angle between ecliptic and equatorial coordinate system */
ecl = DEG_TO_RAD * (23.4393 - 3.563E-7 * actTime);
/* 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) */
xv = planet.a * (cos(eccAnom) - planet.e);
yv = planet.a * (sqrt(1.0 - planet.e*planet.e) * sin(eccAnom));
v = atan2(yv, xv);
r = sqrt ( xv*xv + yv*yv);
/* 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));
yh = r * ( sin(planet.N) * cos(v+planet.w) + cos(planet.N) * sin(v+planet.w) * cos(planet.i));
xh = r * (cos (planet.N) * cos (v + planet.w) -
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));
/* calculate the ecliptic longitude and latitude */
/*
lonecl = atan2(yh, xh);
latecl = atan2(zh, sqrt ( xh*xh + yh*yh));
*/
/* calculate the solar position */
SolarPosition = fgCalcSunPos(theSun);
xg = xh + SolarPosition.xs;
yg = yh + SolarPosition.ys;
xg = xh + solarPosition.xs;
yg = yh + solarPosition.ys;
zg = zh;
xe = xg;
@ -91,7 +82,6 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
result.RightAscension = atan2(ye,xe);
result.Declination = atan2(ze, sqrt(xe*xe + ye*ye));
/* Let's calculate the brightness of the planet */
R = sqrt ( xg*xg + yg*yg + zg*zg);
@ -117,7 +107,9 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
ir = 0.4897394;
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);
result.magnitude = -9.0 + 5*log10( r*R ) + 0.044 * FV + ring_magn;
break;
@ -145,15 +137,18 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
void fgPlanetsInit( void )
{
struct fgLIGHT *l;
int i;
struct CelestialCoord pltPos;
double magnitude;
l = &cur_light_params;
/* if the display list was already built during a previous init,
recycle it */
then recycle it */
if (planets)
if (planets) {
xglDeleteLists(planets, 1);
}
planets = xglGenLists(1);
xglNewList( planets, GL_COMPILE );
@ -166,10 +161,6 @@ void fgPlanetsInit( void )
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 */
@ -182,15 +173,24 @@ void fgPlanetsInit( void )
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) );
/* Add planets to the display list, based on sun_angle and current
magnitude It's pretty experimental... */
if ((double) (l->sun_angle - FG_PI_2) >
((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) *
cos (pltPos.Declination),
50000.0 * sin (pltPos.RightAscension) *
cos (pltPos.Declination),
50000.0 * sin (pltPos.Declination));
}
}
xglEnd();
xglEndList();
@ -204,10 +204,15 @@ void fgPlanetsRender( void ) {
/* $Log$
/* Revision 1.6 1998/02/12 21:59:36 curt
/* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* Revision 1.7 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.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
* 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

View file

@ -25,26 +25,23 @@
#include <GL/glut.h>
#include <XGL/xgl.h>
#include <Time/fg_time.h>
#include <Main/views.h>
#include <Astro/orbits.h>
#include <Astro/sun.h>
#include <Main/fg_debug.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;
static struct CelestialCoord sunPos;
float xSun, ySun, zSun;
fgSUNPOS solarPosition;
struct SunPos fgCalcSunPos(struct OrbElements params)
void fgCalcSunPos(struct OrbElements params)
{
double
EccAnom, lonSun,
xv, yv, v, r;
struct SunPos
solarPosition;
double EccAnom, xv, yv, v, r;
/* calculate the eccentric anomaly */
EccAnom = fgCalcEccAnom(params.M, params.e);
@ -56,37 +53,31 @@ struct SunPos fgCalcSunPos(struct OrbElements params)
r = sqrt(xv*xv + yv*yv);
/* 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
coordinates (xs, ys) */
solarPosition.xs = r * cos(lonSun);
solarPosition.ys = r * sin(lonSun);
/* convert true longitude and distance to ecliptic rectangular
geocentric coordinates (xs, ys) */
solarPosition.xs = r * cos (solarPosition.lonSun);
solarPosition.ys = r * sin (solarPosition.lonSun);
solarPosition.dist = r;
return solarPosition;
/* return solarPosition; */
}
struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
{
struct CelestialCoord
result;
struct SunPos
SolarPosition;
double
xe, ye, ze, ecl, actTime;
struct CelestialCoord result;
double xe, ye, ze, ecl, actTime;
/* calculate the angle between ecliptic and equatorial coordinate system */
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 */
SolarPosition = fgCalcSunPos(params);
/* convert ecliptic coordinates to equatorial rectangular geocentric coordinates */
xe = SolarPosition.xs;
ye = SolarPosition.ys * cos(ecl);
ze = SolarPosition.ys * sin(ecl);
/* convert ecliptic coordinates to equatorial rectangular
geocentric coordinates */
xe = solarPosition.xs;
ye = solarPosition.ys * cos (ecl);
ze = solarPosition.ys * sin (ecl);
/* and finally... Calulate Right Ascention and Declination */
result.RightAscension = atan2( ye, xe);
@ -100,6 +91,7 @@ void fgSunInit( void ) {
struct fgLIGHT *l;
struct fgTIME *t;
struct fgVIEW *v;
float xSun, ySun, zSun;
/* GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 }; */
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");
// Calculate basic sun position
fgSolarSystemUpdate(&(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,
"Sun found at %f (ra), %f (dec)\n",
sunPos.RightAscension, sunPos.Declination);
@ -162,29 +159,12 @@ void fgSunInit( void ) {
"Sun Angle : %f\n" ,
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();
xglTranslatef(xSun, ySun, zSun);
xglScalef(1400, 1400, 1400);
/*xglColor3f(0.85, 0.65, 0.05);*/
xglColor3f(amb[0], amb[1], amb[2]);
glutSolidSphere(1.0, 10, 10);
xglPopMatrix();
/* xglEnable( GL_LIGHTING ); */
xglEndList();
}
@ -196,10 +176,15 @@ void fgSunRender( void ) {
/* $Log$
/* Revision 1.6 1998/02/12 21:59:39 curt
/* Incorporated code changes contributed by Charlie Hotchkiss
/* <chotchkiss@namg.us.anritsu.com>
/* Revision 1.7 1998/02/23 19:07:56 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.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
* To version 0.29
*

View file

@ -27,7 +27,10 @@
#define _SUN_H
struct SunPos fgCalcSunPos(struct OrbElements sunParams);
extern struct fgSUNPOS solarPosition;
void fgCalcSunPos (struct OrbElements sunParams);
extern struct OrbElements pltOrbElements[9];
/* Initialize the Sun */
@ -41,9 +44,14 @@ void fgSunRender( void );
/* $Log$
/* Revision 1.3 1998/01/22 02:59:29 curt
/* Changed #ifdef FILE_H to #ifdef _FILE_H
/* Revision 1.4 1998/02/23 19:07:57 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.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
* Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler.

View file

@ -128,7 +128,7 @@ enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
typedef struct {
int x;
int y;
} POINT;
} FG_POINT;
// CLO 2/21/98 - added to fix compile error
typedef struct {
@ -136,7 +136,7 @@ typedef struct {
int right;
int top;
int bottom;
} RECT;
} FG_RECT;
typedef struct {
// Parametric defined members
@ -155,7 +155,7 @@ typedef struct {
// Pre-calculated members.
int scr_span;
int mid_scr;
RECT scrn_pos; // Screen rectangle for inicator
FG_RECT scrn_pos; // Screen rectangle for inicator
// Replaces previous parameters as:
// scr_pos -> left,bottom
// scr_max -> top, right
@ -166,7 +166,7 @@ typedef struct {
typedef struct {
int type;
RECT position;
FG_RECT position;
int div_min;
int div_max;
int orientation;
@ -178,7 +178,7 @@ typedef struct {
typedef struct {
int type;
POINT scrn_pos;
FG_POINT scrn_pos;
int scr_width;
int scr_height;
int scr_hole;
@ -205,7 +205,7 @@ typedef struct {
typedef struct{
int type;
POINT scrn_pos;
FG_POINT scrn_pos;
int scr_width;
int scr_hole;
int tee_height;
@ -214,12 +214,12 @@ typedef struct{
} HUD_horizon, *pHUDhorizon;
typedef struct {
POINT scrn_pos;
FG_POINT scrn_pos;
double(*load_value)(void);
} HUD_control_surfaces, *pHUDControlSurfaces;
typedef struct {
POINT scrn_pos; // ctrl_x, ctrl_y
FG_POINT scrn_pos; // ctrl_x, ctrl_y
int ctrl_length;
int orientation;
int alignment;
@ -233,7 +233,7 @@ typedef struct {
typedef struct {
int type;
POINT scrn_pos;
FG_POINT scrn_pos;
int size;
int blink;
int justify;
@ -377,9 +377,14 @@ void fgUpdateHUD2( Hptr hud ); // Future use?
#endif // _HUD_H
/* $Log$
/* Revision 1.14 1998/02/21 14:53:14 curt
/* Added Charlie's HUD changes.
/* Revision 1.15 1998/02/23 19:07:57 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.14 1998/02/21 14:53:14 curt
* Added Charlie's HUD changes.
*
* Revision 1.13 1998/02/20 00:16:22 curt
* Thursday's tweaks.
*

View file

@ -252,7 +252,6 @@ COCKPIT cockpit_;
SCALAR Simtime;
/* #define DEFAULT_TERM_UPDATE_HZ 20 */ /* original value */
#define DEFAULT_TERM_UPDATE_HZ 20
#define DEFAULT_MODEL_HZ 120
#define DEFAULT_END_TIME 3600.
@ -915,6 +914,11 @@ int fgLaRCsim_2_Flight (fgFLIGHT *f) {
/* Flight Gear Modification Log
*
* $Log$
* Revision 1.17 1998/02/23 19:07:58 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.16 1998/02/07 15:29:38 curt
* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
* <chotchkiss@namg.us.anritsu.com>

View file

@ -211,6 +211,21 @@ int fgInitSubsystems( void ) {
// FG_Runway_altitude = 920.0 + 100;
// FG_Altitude = FG_Runway_altitude + 3.758099;
// probably interesting for european team members
// That is: If I can get the scenery to work -;) (Durk)
// Initial Position: Groningen Airport Eelde, the netherlands
// FG_Longitude = ( 6.583333 ) * DEG_TO_RAD;
// FG_Latitude = ( 53.125 ) * DEG_TO_RAD;
// FG_Runway_altitude = 920.0;
// FG_Altitude = FG_Runway_altitude + 3.758099;
// Initial Position: Schiphol Amsterdam Airport, the netherlands
// FG_Longitude = ( -4.7641667 ) * DEG_TO_RAD;
// FG_Latitude = ( 52.308056 ) * DEG_TO_RAD;
// FG_Runway_altitude = 920.0;
// FG_Altitude = FG_Runway_altitude + 3.758099;
// Test Position
// FG_Longitude = ( -111.18 ) * DEG_TO_RAD;
// FG_Latitude = ( 33.70 ) * DEG_TO_RAD;
@ -281,9 +296,6 @@ int fgInitSubsystems( void ) {
fgViewInit(v);
fgViewUpdate(f, v, l);
/* Initialize shared sun position and sun_vec */
fgEventRegister( "fgUpdateSunPos()", fgUpdateSunPos, FG_EVENT_READY, 1000 );
/* Initialize the weather modeling subsystem */
fgWeatherInit();
@ -312,7 +324,7 @@ int fgInitSubsystems( void ) {
fgEventRegister("fgPlanetsInit()", fgPlanetsInit, FG_EVENT_READY, 600000);
// Initialize the sun's position
fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 60000 );
fgEventRegister("fgSunInit()", fgSunInit, FG_EVENT_READY, 30000 );
// Intialize the moon's position
fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 );
@ -381,9 +393,14 @@ int fgInitSubsystems( void ) {
/* $Log$
/* Revision 1.48 1998/02/21 14:53:15 curt
/* Added Charlie's HUD changes.
/* Revision 1.49 1998/02/23 19:07:59 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.48 1998/02/21 14:53:15 curt
* Added Charlie's HUD changes.
*
* Revision 1.47 1998/02/19 13:05:53 curt
* Incorporated some HUD tweaks from Michelle America.
* Tweaked the sky's sunset/rise colors.

View file

@ -5,7 +5,7 @@
#---------------------------------------------------------------------------
FG_VERSION_MAJOR = 0
FG_VERSION_MINOR = 35
FG_VERSION_MINOR = 36
FG_VERSION = $(FG_VERSION_MAJOR).$(FG_VERSION_MINOR)
@ -38,8 +38,12 @@ TAR = tar
# -g - Compile with debugging symbols
# -Wall - Enable full compiler warnings
# -O2 - Enable compiler optimization
# -O3 -fomit-frame-pointer -funroll-all-loops -ffast-math
# - Other potential compiler optimization flags
#
# Other potential compiler optimization flags:
#
# -O3 -fPIC -funroll-loops -mpentium -malign-loops=2
# -malign-jumps=2 -malign-functions=2 -fexpensive-optimizations
# -pedantic -ffast-math
#
#---------------------------------------------------------------------------

View file

@ -43,13 +43,14 @@
#include <stdio.h>
#include <time.h>
#include <Time/sunpos.h>
#include <Time/fg_time.h>
#include <Astro/orbits.h>
#include <Include/fg_constants.h>
#include <Main/views.h>
#include <Math/fg_geodesy.h>
#include <Math/mat3.h>
#include <Math/polar.h>
#include <Time/fg_time.h>
#include <Time/sunpos.h>
#undef E
@ -96,8 +97,8 @@
*/
#define MeanObliquity (23.440592*(FG_2PI/360))
static double solve_keplers_equation(double);
static double sun_ecliptic_longitude(time_t);
/* static double solve_keplers_equation(double); */
/* static double sun_ecliptic_longitude(time_t); */
static void ecliptic_to_equatorial(double, double, double *, double *);
static double julian_date(int, int, int);
static double GST(time_t);
@ -106,6 +107,7 @@ static double GST(time_t);
* solve Kepler's equation via Newton's method
* (after duffett-smith, section 47)
*/
/*
static double solve_keplers_equation(double M) {
double E;
double delta;
@ -119,13 +121,14 @@ static double solve_keplers_equation(double M) {
return E;
}
*/
/* compute ecliptic longitude of sun (in radians) (after
* duffett-smith, section 47) */
/*
static double sun_ecliptic_longitude(time_t ssue) {
/* time_t ssue; seconds since unix epoch */
// time_t ssue; // seconds since unix epoch
double D, N;
double M_sun, E;
double v;
@ -144,6 +147,7 @@ static double sun_ecliptic_longitude(time_t ssue) {
return (v + OmegaBar_g);
}
*/
/* convert from ecliptic to equatorial coordinates (after
@ -239,12 +243,13 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) {
/* double *lat; (return) latitude */
/* double *lon; (return) longitude */
double lambda;
/* double lambda; */
double alpha, delta;
double tmp;
lambda = sun_ecliptic_longitude(ssue);
ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta);
/* lambda = sun_ecliptic_longitude(ssue); */
/* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */
ecliptic_to_equatorial (solarPosition.lonSun, 0.0, &alpha, &delta);
tmp = alpha - (FG_2PI/24)*GST(ssue);
if (tmp < -FG_PI) {
@ -373,9 +378,14 @@ void fgUpdateSunPos( void ) {
/* $Log$
/* Revision 1.25 1998/02/09 15:07:53 curt
/* Minor tweaks.
/* Revision 1.26 1998/02/23 19:08:00 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.25 1998/02/09 15:07:53 curt
* Minor tweaks.
*
* Revision 1.24 1998/01/27 00:48:07 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.