From bcf7870083cf4b38b9a6d4e15b16abdd85585432 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 13 Aug 1997 20:23:49 +0000 Subject: [PATCH] The interface to sunpos now updates a global structure rather than returning current sun position. --- Time/sunpos.c | 30 ++++++++++++++++++++++++++++-- Time/sunpos.h | 5 ++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Time/sunpos.c b/Time/sunpos.c index 3eb00e22b..ecb8fcffc 100644 --- a/Time/sunpos.c +++ b/Time/sunpos.c @@ -44,7 +44,11 @@ #include #include "sunpos.h" +#include "fg_time.h" #include "../constants.h" +#include "../Math/fg_geodesy.h" +#include "../Math/polar.h" + #undef E @@ -253,10 +257,32 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) { } +/* update the cur_time_params structure with the current sun position */ +void fgUpdateSunPos() { + struct time_params *t; + double sun_gd_lat, sl_radius; + static int time_warp = 0; + + t = &cur_time_params; + + time_warp += 600; /* increase this to make the world spin real fast */ + + fgSunPosition(time(NULL) + time_warp, &t->sun_lon, &sun_gd_lat); + + fgGeodToGeoc(sun_gd_lat, 0.0, &sl_radius, &t->sun_gc_lat); + + t->fg_sunpos = fgPolarToCart(t->sun_lon, t->sun_gc_lat, sl_radius); +} + + /* $Log$ -/* Revision 1.2 1997/08/06 00:24:32 curt -/* Working on correct real time sun lighting. +/* Revision 1.3 1997/08/13 20:23:49 curt +/* The interface to sunpos now updates a global structure rather than returning +/* current sun position. /* + * Revision 1.2 1997/08/06 00:24:32 curt + * Working on correct real time sun lighting. + * * Revision 1.1 1997/08/01 15:27:56 curt * Initial revision. * diff --git a/Time/sunpos.h b/Time/sunpos.h index ded7a040c..767728485 100644 --- a/Time/sunpos.h +++ b/Time/sunpos.h @@ -43,9 +43,8 @@ #include -/* given a particular time (expressed in seconds since the unix - * epoch), compute position on the earth (lat, lon) such that sun is - * directly overhead. (lat, lon are reported in radians */ +/* update the cur_time_params structure with the current sun position */ +void fgUpdateSunPos(); void fgSunPosition(time_t ssue, double *lon, double *lat); -- 2.39.2