1 /*
2  *  - - - - - - - - - -
3  *   g a l _ c 2 t p e
4  *  - - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *  Form the celestial to terrestrial matrix given the date, the UT1, the
11  *  nutation and the polar motion.  IAU 2000.
12  *
13  *  This routine is an independent translation of a FORTRAN routine
14  *  that is part of IAU's SOFA software collection.
15  *
16  *  Status:
17  *
18  *     support routine.
19  *
20  *  Given:
21  *
22  *     tta,ttb             d        TT as a 2-part Julian Date (Note 1)
23  *     uta,utb             d        UT1 as a 2-part Julian Date (Note 1)
24  *     dpsi,deps           d        nutation (Note 2)
25  *     xp,yp               d        coordinates of the pole (radians, Note 3)
26  *
27  *  Returned:
28  *
29  *     rc2t             d[3][3]     celestial-to-terrestrial matrix (Note 4)
30  *
31  *  Notes:
32  *
33  *  1) The TT and UT1 dates tta+ttb and uta+utb are Julian Dates,
34  *     apportioned in any convenient way between the arguments uta and
35  *     utb.  For example, JD(UT1)=2450123.7 could be expressed in any of
36  *     these ways, among others:
37  *
38  *             uta            utb
39  *
40  *         2450123.7          0.0        (JD method)
41  *         2451545.0      -1421.3        (J2000 method)
42  *         2400000.5      50123.2        (MJD method)
43  *         2450123.5          0.2        (date & time method)
44  *
45  *     The JD method is the most natural and convenient to use in
46  *     cases where the loss of several decimal digits of resolution is
47  *     acceptable.  The J2000 and MJD methods are good compromises
48  *     between resolution and convenience.  In the case of uta,utb, the
49  *     date & time method is best matched to the Earth rotation angle
50  *     algorithm used:  maximum accuracy (or, at least, minimum noise) is
51  *     delivered when the uta argument is for 0hrs UT1 on the day in
52  *     question and the utb argument lies in the range 0 to 1, or vice
53  *     versa.
54  *
55  *  2) The caller is responsible for providing the nutation components;
56  *     they are in longitude and obliquity, in radians and are with
57  *     respect to the equinox and ecliptic of date.  For high-accuracy
58  *     applications, free core nutation should be included as well as
59  *     any other relevant corrections to the position of the CIP.
60  *
61  *  3) xp and yp are the "coordinates of the pole", in radians, which
62  *     position the Celestial Intermediate Pole in the International
63  *     Terrestrial Reference System (see IERS Conventions 2003).  In a
64  *     geocentric right-handed triad u,v,w, where the w-axis points at
65  *     the north geographic pole, the v-axis points towards the origin
66  *     of longitudes and the u axis completes the system, xp = +u and
67  *     yp = -v.
68  *
69  *  4) The matrix RC2T transforms from celestial to terrestrial
70  *     coordinates:
71  *
72  *        [TRS]  =  rpom * R_3(gst) * rbpn * [CRS]
73  *
74  *               =  rc2t * [CRS]
75  *
76  *     where [CRS] is a vector in the Geocentric Celestial Reference
77  *     System and [TRS] is a vector in the International Terrestrial
78  *     Reference System (see IERS Conventions 2003), rbpn is the
79  *     bias-precession-nutation matrix, gst is the Greenwich (apparent)
80  *     Sidereal Time and rpom is the polar motion matrix.
81  *
82  *  5) Although its name does not include "00", this routine is in fact
83  *     specific to the IAU 2000 models.
84  *
85  *  Called:
86  *
87  *     gal_pn00           bias/precession/nutation results, IAU 2000
88  *     gal_gmst00         Greenwich mean sidereal time, IAU 2000
89  *     gal_sp00           the TIO locator s', IERS 2000
90  *     gal_ee00           equation of the equinoxes, IAU 2000
91  *     gal_pom00          polar motion matrix
92  *     gal_c2teqx         form equinox-based celestial-to-terrestrial matrix
93  *
94  *  References:
95  *
96  *     McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
97  *     IERS Technical Note No. 32, BKG (2004)
98  *
99  *  This revision:
100  *
101  *     2007 June 1 ( c version 2008 January 18 )
102  *
103  *
104  *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
105  *
106  *-----------------------------------------------------------------------
107  */
108 
109 #include "gal_c2tpe.h"
110 #include "gal_pn00.h"
111 #include "gal_gmst00.h"
112 #include "gal_sp00.h"
113 #include "gal_ee00.h"
114 #include "gal_pom00.h"
115 #include "gal_c2teqx.h"
116 
117 void
gal_c2tpe(double tta,double ttb,double uta,double utb,double dpsi,double deps,double xp,double yp,double rc2t[3][3])118 gal_c2tpe
119  (
120     double tta,
121     double ttb,
122     double uta,
123     double utb,
124     double dpsi,
125     double deps,
126     double xp,
127     double yp,
128     double rc2t[3][3]
129  )
130 {
131 
132     double epsa, gmst, ee, sp,
133            rb[3][3], rp[3][3], rbp[3][3], rn[3][3], rbpn[3][3], rpom[3][3] ;
134 
135 /*
136  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
137  */
138 
139 /*
140  * Form the celestial-to-true matrix for this TT.
141  */
142 
143     gal_pn00 ( tta, ttb, dpsi, deps, &epsa, rb, rp, rbp, rn, rbpn ) ;
144 
145 /*
146  * Predict the Greenwich Mean Sidereal Time for this UT1 and TT.
147  */
148 
149     gmst = gal_gmst00 ( uta, utb, tta, ttb ) ;
150 
151 /*
152  * Predict the equation of the equinoxes given TT and nutation.
153  */
154 
155     ee = gal_ee00 ( tta, ttb, epsa, dpsi ) ;
156 
157 /*
158  * Estimate s'.
159  */
160 
161     sp = gal_sp00 ( tta, ttb ) ;
162 
163 /*
164  * Form the polar motion matrix.
165  */
166 
167     gal_pom00 ( xp, yp, sp, rpom ) ;
168 
169 /*
170  * Combine to form the celestial-to-terrestrial matrix.
171  */
172 
173     gal_c2teqx ( rbpn, gmst + ee, rpom, rc2t ) ;
174 
175 /*
176  * Finished.
177  */
178 
179 }
180 
181 /*
182  *  gal - General Astrodynamics Library
183  *  Copyright (C) 2008 Paul C. L. Willmott
184  *
185  *  This program is free software; you can redistribute it and/or modify
186  *  it under the terms of the GNU General Public License as published by
187  *  the Free Software Foundation; either version 2 of the License, or
188  *  (at your option) any later version.
189  *
190  *  This program is distributed in the hope that it will be useful,
191  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
192  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
193  *  GNU General Public License for more details.
194  *
195  *  You should have received a copy of the GNU General Public License along
196  *  with this program; if not, write to the Free Software Foundation, Inc.,
197  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
198  *
199  *  Contact:
200  *
201  *  Paul Willmott
202  *  vp9mu@amsat.org
203  */
204