tdb.c 1.07 KB
Newer Older
Jeroen Vreeken's avatar
Jeroen Vreeken committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Find Barycentric Dynamical Time from Terrestrial Dynamical Time.
   Reference: Astronomical Almanac, page B5.  */

/* radians per arc second */
#define STR 4.8481368110953599359e-6

/* 2000 January 1.5 */
#define J2000 2451545.0

#if __STDC__
double sin (double);
double floor (double);
#else
double sin(), floor();
#endif

/* Argument JED is a Julian date, in TDT.
   Output is the corresponding date in TDB.  */

double tdb(JED)
double JED;
{
double M, T;

/* Find time T in Julian centuries from J2000.  */
T = (JED - J2000)/36525.0;

/* Mean anomaly of sun = l' (J. Laskar) */
M = 129596581.038354 * T +  1287104.76154;

/* Reduce arc seconds mod 360 degrees.  */
M = M - 1296000.0 * floor( M/1296000.0 );

M += ((((((((
  1.62e-20 * T
- 1.0390e-17 ) * T
- 3.83508e-15 ) * T
+ 4.237343e-13 ) * T
+ 8.8555011e-11 ) * T
- 4.77258489e-8 ) * T
- 1.1297037031e-5 ) * T
+ 1.4732069041e-4 ) * T
- 0.552891801772 ) * T * T;
M *= STR;
/* TDB - TDT, in seconds.  */
T = 0.001658 * sin(M) + 0.000014 * sin(M+M);

T = JED + T / 86400.0;
return(T);
}