1 /*
2  *  - - - - - - - - - - -
3  *   g a l _ t t 2 m t c
4  *  - - - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *     This routine converts a TT jd date to a Mars Coordinated
11  *     Time (MTC) date. Mars Coordinated Time is the Mean Solar
12  *     Time on the Mars prime meridian.
13  *
14  *  Status:
15  *
16  *     support routine.
17  *
18  *  Given:
19  *
20  *     tt1                 d        TT date part 1 ( see Note 1 )
21  *     tt2                 d        TT date part 2 ( see Note 1 )
22  *
23  *  Returned:
24  *
25  *     *mtc1               d        MTC date part 1 ( see Note 2 )
26  *     *mtc2               d        MTC date part 2 ( see Note 2 )
27  *
28  *  Notes:
29  *
30  *  1) The Julian Date is apportioned in any convenient way between
31  *     the arguments tai1 and tai2.  For example, JD=2450123.7 could
32  *     be expressed in any of these ways, among others:
33  *
34  *               tt1          tt2
35  *
36  *         2450123.7          0.0   (JD method)
37  *         2451545.0      -1421.3   (J2000 method)
38  *         2400000.5      50123.2   (MJD method)
39  *         2450123.5          0.2   (date & time method)
40  *
41  *  2) mtc1 contains the sol number, and mtc2 the fractional part of the
42  *     sol. A Mars "day" is called a "sol".
43  *
44  *  3) As defined, consistent with the terrestrial convention for Mean
45  *     Solar Time, JD 2451549.5 (2000 January 6 00:00:00) corresponds to
46  *     a near coincidence of the terrestrial Greenwich mean solar
47  *     midnight and the Martian mean solar (prime meridian) midnight. The
48  *     addition of the integer number 44796 assures a positive result
49  *     for any date since JD 2405522 (1873 December 29.5).
50  *
51  *  References:
52  *
53  *     A post-Pathfinder evaluation of areocentric solar coordinates with
54  *     improved timing recipes for Mars seasonal/diurnal climate studies
55  *     by Michael Allison, Megan McEwen,
56  *     Planetary and Space Science 48 (2000) 215-235
57  *
58  *     Mars24 URL: http://www.giss.nasa.gov/tools/mars24/help/algorithm.html
59  *     The referenced URL contains corrections to the referenced article.
60  *
61  *  This revision:
62  *
63  *     2009 January 5
64  *
65  *  Copyright (C) 2009 Paul C. L. Willmott. See notes at end.
66  *
67  *-----------------------------------------------------------------------
68  */
69 
70 #include <math.h>
71 #include "gal_tt2mtc.h"
72 
73 void
gal_tt2mtc(double tt1,double tt2,double * mtc1,double * mtc2)74 gal_tt2mtc
75  (
76     double tt1,
77     double tt2,
78     double *mtc1,
79     double *mtc2
80  )
81 
82 {
83 
84   double mtc ;
85 
86 /*
87  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88  */
89 
90   mtc = ( ( tt1 - 2451549.5 ) + tt2 ) / 1.027491252 + 44796.0 - 0.00096;
91   *mtc1 = floor ( mtc ) ;
92   *mtc2 = mtc - (*mtc1) ;
93 
94 /*
95  * Finished.
96  */
97 
98 }
99 
100 /*
101  *  gal - General Astrodynamics Library
102  *  Copyright (C) 2009 Paul C. L. Willmott
103  *
104  *  This program is free software; you can redistribute it and/or modify
105  *  it under the terms of the GNU General Public License as published by
106  *  the Free Software Foundation; either version 2 of the License, or
107  *  (at your option) any later version.
108  *
109  *  This program is distributed in the hope that it will be useful,
110  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
111  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
112  *  GNU General Public License for more details.
113  *
114  *  You should have received a copy of the GNU General Public License along
115  *  with this program; if not, write to the Free Software Foundation, Inc.,
116  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
117  *
118  *  Contact:
119  *
120  *  Paul Willmott
121  *  vp9mu@amsat.org
122  */
123 
124