From 14efd49c8be0fe57b0fd34890b33968841a6628b Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 20 Sep 1997 03:34:25 +0000 Subject: [PATCH] Still trying to get those durned stars aligned properly. --- Main/depend | 6 ++++-- Scenery/depend | 3 ++- Scenery/stars.c | 19 +++++++++++-------- Time/depend | 15 ++++++++------- Time/fg_time.c | 44 +++++++++++++++++++++++++++----------------- Time/fg_time.h | 10 +++++++--- 6 files changed, 59 insertions(+), 38 deletions(-) diff --git a/Main/depend b/Main/depend index a468e5feb..33d6d38e5 100644 --- a/Main/depend +++ b/Main/depend @@ -15,7 +15,8 @@ GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../types.h \ ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \ ../Math/../types.h ../Scenery/mesh.h ../Scenery/scenery.h \ ../Scenery/../types.h ../Time/fg_time.h ../Time/../types.h \ - ../Time/fg_timer.h ../Time/sunpos.h ../Weather/weather.h + ../Time/../Flight/flight.h ../Time/fg_timer.h ../Time/sunpos.h \ + ../Weather/weather.h fg_init.o: fg_init.c fg_init.h views.h ../types.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \ @@ -26,7 +27,8 @@ fg_init.o: fg_init.c fg_init.h views.h ../types.h ../Flight/flight.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \ ../Scenery/scenery.h ../Scenery/../types.h ../Scenery/stars.h \ - ../Time/sunpos.h ../Time/../types.h ../Weather/weather.h + ../Time/fg_time.h ../Time/../types.h ../Time/../Flight/flight.h \ + ../Time/sunpos.h ../Weather/weather.h views.o: views.c views.h ../types.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../constants.h \ diff --git a/Scenery/depend b/Scenery/depend index 2fcd2dea7..faadb7fa8 100644 --- a/Scenery/depend +++ b/Scenery/depend @@ -16,4 +16,5 @@ stars.o: stars.c stars.h ../constants.h ../general.h ../GLUT/views.h \ ../GLUT/../Flight/LaRCsim/../flight.h ../GLUT/../Math/mat3.h \ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../limits.h + ../Aircraft/../Controls/../limits.h ../Time/fg_time.h \ + ../Time/../types.h ../Time/../Flight/flight.h diff --git a/Scenery/stars.c b/Scenery/stars.c index c45265bbd..6c3ff954f 100644 --- a/Scenery/stars.c +++ b/Scenery/stars.c @@ -233,12 +233,12 @@ void fgStarsRender() { glTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z ); - angle = FG_2PI * t->lst / 24.0; - /* warp += 1.0 * DEG_TO_RAD; */ - warp = 15.0 * DEG_TO_RAD; - glRotatef( -(angle+warp) * RAD_TO_DEG, 0.0, 0.0, 1.0 ); - printf("Rotating stars by %.2f + %.2f\n", -angle * RAD_TO_DEG, - -warp * RAD_TO_DEG); + angle = t->gst * 15.0; /* 15 degrees per hour rotation */ + /* warp += 1.0; */ + /* warp = 15.0; */ + warp = 0.0; + glRotatef( -(angle+warp), 0.0, 0.0, 1.0 ); + printf("Rotating stars by %.2f degrees + %.2f degrees\n",-angle,-warp); glCallList(stars[i]); @@ -252,9 +252,12 @@ void fgStarsRender() { /* $Log$ -/* Revision 1.9 1997/09/18 16:20:09 curt -/* At dusk/dawn add/remove stars in stages. +/* Revision 1.10 1997/09/20 03:34:32 curt +/* Still trying to get those durned stars aligned properly. /* + * Revision 1.9 1997/09/18 16:20:09 curt + * At dusk/dawn add/remove stars in stages. + * * Revision 1.8 1997/09/16 22:14:52 curt * Tweaked time of day lighting equations. Don't draw stars during the day. * diff --git a/Time/depend b/Time/depend index 2ba06afdd..ab061cf3d 100644 --- a/Time/depend +++ b/Time/depend @@ -1,11 +1,12 @@ -fg_time.o: fg_time.c fg_time.h ../types.h +fg_time.o: fg_time.c fg_time.h ../types.h ../Flight/flight.h \ + ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ + ../Flight/LaRCsim/../flight.h ../constants.h ../Time/fg_time.h fg_timer.o: fg_timer.c fg_timer.h -sidereal.o: sidereal.c -sunpos.o: sunpos.c sunpos.h ../types.h fg_time.h ../constants.h \ - ../GLUT/views.h ../GLUT/../types.h ../GLUT/../Flight/flight.h \ - ../GLUT/../Flight/Slew/slew.h \ - ../GLUT/../Flight/LaRCsim/ls_interface.h \ - ../GLUT/../Flight/LaRCsim/../flight.h ../GLUT/../Math/mat3.h \ +sidereal.o: sidereal.c ../constants.h +sunpos.o: sunpos.c sunpos.h ../types.h fg_time.h ../Flight/flight.h \ + ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ + ../Flight/LaRCsim/../flight.h ../constants.h ../GLUT/views.h \ + ../GLUT/../types.h ../GLUT/../Flight/flight.h ../GLUT/../Math/mat3.h \ ../Math/fg_geodesy.h ../Math/mat3.h ../Math/polar.h \ ../Math/../types.h ttest.o: ttest.c diff --git a/Time/fg_time.c b/Time/fg_time.c index d5b34c169..4b9c23075 100644 --- a/Time/fg_time.c +++ b/Time/fg_time.c @@ -45,7 +45,7 @@ struct fgTIME cur_time_params; /* Initialize the time dependent variables */ void fgTimeInit(struct fgTIME *t) { - t->lst_diff = -9999.0; + t->gst_diff = -9999.0; } @@ -112,6 +112,8 @@ double utc_gst (double mjd) { x /= 3600.0; gst = (1.0/SIDRATE)*hr + x; + printf("gst => %.4f\n", gst); + return(gst); } @@ -136,7 +138,7 @@ double sidereal_precise (double mjd, double lng) { gst = utc_gst (mjd); lst = gst - RADHR (lng); lst -= 24.0*floor(lst/24.0); - printf ("%7.4f\n", lst); + /* printf ("%7.4f\n", lst); */ /* that's all */ return (lst); @@ -199,7 +201,7 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) { /* Update the time dependent variables */ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) { - double lst_precise, lst_course; + double gst_precise, gst_course; static long int warp = 0; /* get current Unix calendar time (in seconds) */ @@ -230,31 +232,39 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) { printf("Current Longitude = %.3f\n", FG_Longitude * RAD_TO_DEG); /* Calculate local side real time */ - if ( t->lst_diff < -100.0 ) { + if ( t->gst_diff < -100.0 ) { /* first time through do the expensive calculation & cheap calculation to get the difference. */ - printf("First time, doing precise lst\n"); - t->lst = lst_precise = - sidereal_precise(t->mjd, -(FG_Longitude * RAD_TO_DEG)); - lst_course = - sidereal_course(t->gmt, t->cur_time, -(FG_Longitude * RAD_TO_DEG)); - t->lst_diff = lst_precise - lst_course; - } else { - /* course + difference should drift off very slowly */ + printf("First time, doing precise gst\n"); + t->gst = gst_precise = sidereal_precise(t->mjd, 0.00); + gst_course = sidereal_course(t->gmt, t->cur_time, 0.00); + t->gst_diff = gst_precise - gst_course; + t->lst = sidereal_course(t->gmt, t->cur_time, -(FG_Longitude * RAD_TO_DEG)) - + t->lst_diff; + + t->gst_diff; + } else { + /* course + difference should drift off very slowly */ + t->gst = + sidereal_course(t->gmt, t->cur_time, 0.00) + t->gst_diff; + t->lst = + sidereal_course(t->gmt, t->cur_time, -(FG_Longitude * RAD_TO_DEG)) + + t->gst_diff; } - printf("Current Sidereal Time = %.3f (%.3f) (diff = %.3f)\n", t->lst, + printf("Current lon=0.00 Sidereal Time = %.3f\n", t->gst); + printf("Current LOCAL Sidereal Time = %.3f (%.3f) (diff = %.3f)\n", t->lst, sidereal_precise(t->mjd, -(FG_Longitude * RAD_TO_DEG)), - t->lst_diff); + t->gst_diff); } /* $Log$ -/* Revision 1.5 1997/09/16 22:14:52 curt -/* Tweaked time of day lighting equations. Don't draw stars during the day. +/* Revision 1.6 1997/09/20 03:34:34 curt +/* Still trying to get those durned stars aligned properly. /* + * Revision 1.5 1997/09/16 22:14:52 curt + * Tweaked time of day lighting equations. Don't draw stars during the day. + * * Revision 1.4 1997/09/16 15:50:31 curt * Working on star alignment and time issues. * diff --git a/Time/fg_time.h b/Time/fg_time.h index 19f589066..3b8b3f009 100644 --- a/Time/fg_time.h +++ b/Time/fg_time.h @@ -48,9 +48,10 @@ struct fgTIME { double jd; /* Julian date */ double mjd; /* modified Julian date */ + double gst; /* side real time at prime meridian */ double lst; /* local side real time */ - double lst_diff; /* the difference between the precise + double gst_diff; /* the difference between the precise sidereal time algorithm result and the course result. course + diff has good accuracy for the short term */ @@ -77,9 +78,12 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t); /* $Log$ -/* Revision 1.5 1997/09/16 15:50:31 curt -/* Working on star alignment and time issues. +/* Revision 1.6 1997/09/20 03:34:35 curt +/* Still trying to get those durned stars aligned properly. /* + * Revision 1.5 1997/09/16 15:50:31 curt + * Working on star alignment and time issues. + * * Revision 1.4 1997/09/13 02:00:08 curt * Mostly working on stars and generating sidereal time for accurate star * placement.