33#define days_since_2000_Jan_0(y,m,d) \
34 (367L*(y)-((7*((y)+(((m)+9)/12)))/4)+((275*(m))/9)+(d)-730530L)
37# define PI 3.1415926535897932384
40#define RADEG ( 180.0 / PI )
41#define DEGRAD ( PI / 180.0 )
45#define sind(x) sin((x)*DEGRAD)
46#define cosd(x) cos((x)*DEGRAD)
47#define tand(x) tan((x)*DEGRAD)
49#define atand(x) (RADEG*atan(x))
50#define asind(x) (RADEG*asin(x))
51#define acosd(x) (RADEG*acos(x))
52#define atan2d(y,x) (RADEG*atan2(y,x))
69#define INV360 (1.0 / 360.0)
74static double astro_revolution(
double x)
82static double astro_rev180(
double x )
113static double astro_GMST0(
double d)
121 sidtim0 = astro_revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d);
133static void astro_sunpos(
double d,
double *lon,
double *r)
144 M = astro_revolution(356.0470 + 0.9856002585 * d);
145 w = 282.9404 + 4.70935E-5 * d;
146 e = 0.016709 - 1.151E-9 * d;
152 *r =
sqrt(x*x + y*y);
160static void astro_sun_RA_dec(
double d,
double *
RA,
double *dec,
double *r)
162 double lon, obl_ecl, x, y, z;
165 astro_sunpos(d, &lon, r);
172 obl_ecl = 23.4393 - 3.563E-7 * d;
175 z = y *
sind(obl_ecl);
176 y = y *
cosd(obl_ecl);
228 old_sse = t_loc->
sse;
230 t_loc->
i = t_loc->
s = 0;
239 t_utc->
h = t_utc->
i = t_utc->
s = 0;
243 timestamp = t_utc->
sse;
247 sidtime = astro_revolution(astro_GMST0(d) + 180.0 + lon);
250 astro_sun_RA_dec( d, &sRA, &sdec, &sr );
253 tsouth = 12.0 - astro_rev180(sidtime - sRA) / 15.0;
256 sradius = 0.2666 / sr;
268 *ts_transit = t_utc->
sse + (tsouth * 3600);
273 *ts_rise = *ts_set = t_utc->
sse + (tsouth * 3600);
274 }
else if (cost <= -1.0) {
278 *ts_rise = t_loc->
sse - (12 * 3600);
279 *ts_set = t_loc->
sse + (12 * 3600);
281 t =
acosd(cost) / 15.0;
284 *ts_rise = ((tsouth - t) * 3600) + t_utc->
sse;
285 *ts_set = ((tsouth + t) * 3600) + t_utc->
sse;
287 *h_rise = (tsouth - t);
288 *h_set = (tsouth + t);
294 t_loc->
sse = old_sse;
304 tmp /= (double) 86400;
305 tmp += (double) 2440587.5;
int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit)
double timelib_ts_to_j2000(timelib_sll ts)
double timelib_ts_to_julianday(timelib_sll ts)
timelib_time * timelib_time_ctor(void)
void timelib_time_dtor(timelib_time *t)
void timelib_update_ts(timelib_time *time, timelib_tzinfo *tzi)
struct _timelib_time timelib_time
signed long long timelib_sll