Sun position
Sun position algorithm
|
56 #if defined(BARE_METAL_THREADS)
57 #define startCriticalSection() disableInterrupts()
58 #define endCriticalSection() enableInterrupts()
60 #elif defined(POSIX_THREADS)
63 #define startCriticalSection() pthread_mutex_lock(&mutex)
64 #define endCriticalSection() pthread_mutex_unlock(&mutex)
67 #define startCriticalSection() ((void)0)
68 #define endCriticalSection() ((void)0)
91 LOCAL volatile bool oneAfterIsValid =
false;
94 LOCAL double recalcInterval_cy = 0.0;
97 LOCAL pthread_mutex_t mutex;
112 int fullRecalcInterval_mins,
114 void (*getApparent)(
double j2kTT_cy,
162 double calcTimeTT_cy;
169 REQUIRE(fullRecalcInterval_mins > 0);
173 ret = pthread_mutex_init(&mutex, NULL);
177 callback = getApparent;
182 recalcInterval_cy = fullRecalcInterval_mins / (1440.0 *
JUL_CENT);
185 getApparent(calcTimeTT_cy, last);
188 calcTimeTT_cy += recalcInterval_cy;
189 getApparent(calcTimeTT_cy, next);
192 calcTimeTT_cy += recalcInterval_cy;
193 getApparent(calcTimeTT_cy, oneAfter);
194 oneAfterIsValid =
true;
220 REQUIRE(recalcInterval_cy > 0.0);
222 if (!oneAfterIsValid) {
224 callback(t_cy, oneAfter);
226 startCriticalSection();
227 oneAfterIsValid =
true;
228 endCriticalSection();
270 startCriticalSection();
275 oneAfterIsValid =
false;
276 endCriticalSection();
general.h - definitions of general use to (standard) C programs
V3D_Vector appCirsV
Direction of object in apparent or CIRS coordinates (effectively a unit vector).
This structure contains relatively constant data, and is set up by one of the three functions sky_ini...
#define REQUIRE(test_)
Check preconditions.
astron.h - assorted definitions useful for astronomy
void sky_updateTimes(double j2kUtc_d, const Sky_DeltaTs *d, Sky_Times *t)
Convert the given "J2KD" in the UTC timescale to the other timescales, and pre-calculate some other q...
Struct used for holding an object's coordinates in equatorial apparent or Intermediate coordinates.
void skyfast_getApprox(double t_cy, Sky_TrueEquatorial *approx)
Get the best approximation to the celestial object's apparent coordinates and distance,...
#define LOCAL
C has some very silly default behaviours.
double j2kTT_cy
Julian centuries since J2000.0, TT timescale [T].
#define REQUIRE_NOT_NULL(pointer_)
,
#define SFA
A very small number, used to avoid divide by 0 errors.
This structure contains the continuously varying time (and earth rotation) data, in various forms tha...
double eqEq_rad
Equation of the Equinoxes (radian).
void skyfast_backgroundUpdate(void)
Recalculation of the low frequency quantities.
void skyfast_init(double tStartUtc_d, int fullRecalcInterval_mins, const Sky_DeltaTs *deltas, void(*getApparent)(double j2kTT_cy, Sky_TrueEquatorial *pos))
Initialise those items that take a long time to calculate, but which do not need to be recalculated f...
double timestamp_cy
Time applying to the other figures in this struct (centuries since J2000.0, TT timescale)
#define ASSERT(test_)
Uses standard assert.
double distance_au
Distance to object (Astronomical Units) or 0.0 for far distant objects (that is, those with negligibl...
#define DEFINE_THIS_FILE
Leave DEFINE_THIS_FILE undefined.
#define JUL_CENT
Length of Julian Century in days.
skyfast.h - set up and use interpolation for rapid calculation of a celestial object's apparent coord...
sun.h - routines to calculate the Sun's position
sky0.h - astronomical coordinate conversion for NREL Sun Position Algorithm