1 /*
2  *  - - - - - - - - -
3  *   g a l _ b p 0 0
4  *  - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *  Frame bias and precession, IAU 2000.
11  *
12  *  This routine is an independent translation of a FORTRAN routine
13  *  that is part of IAU's SOFA software collection.
14  *
15  *  Status:
16  *
17  *     canonical model.
18  *
19  *  Given:
20  *
21  *     date,date2          d        TT as a 2-part Julian Date (Note 1)
22  *
23  *  Returned:
24  *
25  *     rb               d[3][3]     frame bias matrix (Note 2)
26  *     rp               d[3][3]     precession matrix (Note 3)
27  *     rbp              d[3][3]     bias-precession matrix (Note 4)
28  *
29  *  Notes:
30  *
31  *  1) The TT date date1+date2 is a Julian Date, apportioned in any
32  *     convenient way between the two arguments.  For example,
33  *     JD(TT)=2450123.7 could be expressed in any of these ways,
34  *     among others:
35  *
36  *            date1         date2
37  *
38  *         2450123.7          0.0        (JD method)
39  *         2451545.0      -1421.3        (J2000 method)
40  *         2400000.5      50123.2        (MJD method)
41  *         2450123.5          0.2        (date & time method)
42  *
43  *     The JD method is the most natural and convenient to use in
44  *     cases where the loss of several decimal digits of resolution
45  *     is acceptable.  The J2000 method is best matched to the way
46  *     the argument is handled internally and will deliver the
47  *     optimum resolution.  The MJD method and the date & time methods
48  *     are both good compromises between resolution and convenience.
49  *
50  *  2) The matrix rb transforms vectors from GCRS to mean J2000 by
51  *     applying frame bias.
52  *
53  *  3) The matrix rp transforms vectors from J2000 mean equator and
54  *     equinox to mean equator and equinox of date by applying
55  *     precession.
56  *
57  *  4) The matrix rbp transforms vectors from GCRS to mean equator and
58  *     equinox of date by applying frame bias then precession. It is the
59  *     product rp x rb.
60  *
61  *  Called:
62  *
63  *     gal_bi00           frame bias components, IAU 2000
64  *     gal_pr00           IAU 2000 precession adjustments
65  *     gal_ir             initialize r-matrix to identity
66  *     gal_rx             rotate around X-axis
67  *     gal_ry             rotate around Y-axis
68  *     gal_rz             rotate around Z-axis
69  *     gal_rxr            product of two r-matrices
70  *
71  *  References:
72  *
73  *     Capitaine, N., Chapront, J., Lambert, S. and Wallace, P.,
74  *     "Expressions for the Celestial Intermediate Pole and Celestial
75  *     Ephemeris Origin consistent with the IAU 2000A precession-nutation
76  *     model", Astronomy & Astrophysics, 400, 1145-1154 (2003)
77  *
78  *     n.b. The celestial ephemeris origin (CEO) was renamed "celestial
79  *     intermediate origin" (CIO) by IAU 2006 Resolution 2.
80  *
81  *  This revision:
82  *
83  *     2007 April 11 ( c version 2008 January 18 )
84  *
85  *
86  *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
87  *
88  *-----------------------------------------------------------------------
89  */
90 
91 #include <math.h>
92 #include "gal_const.h"
93 #include "gal_bp00.h"
94 #include "gal_bi00.h"
95 #include "gal_pr00.h"
96 #include "gal_ir.h"
97 #include "gal_rx.h"
98 #include "gal_ry.h"
99 #include "gal_rz.h"
100 #include "gal_rxr.h"
101 
102 void
gal_bp00(double date1,double date2,double rb[3][3],double rp[3][3],double rbp[3][3])103 gal_bp00
104  (
105     double date1,
106     double date2,
107     double rb[3][3],
108     double rp[3][3],
109     double rbp[3][3]
110  )
111 {
112 
113 /*
114  * J2000 obliquity (Lieske et al. 1977)
115  */
116 
117     double const EPS0 = 84381.448 * GAL_AS2R ;
118 
119     double  t, dpsibi, depsbi, dra0 ;
120     double  psia77, oma77, chia, dpsipr, depspr, psia, oma ;
121 
122 /*
123  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
124  */
125 
126 /*
127  * Interval between fundamental epoch J2000.0 and current date (JC).
128  */
129 
130     t = ( ( date1 - GAL_J2000 ) + date2 ) / GAL_DJC ;
131 
132 /*
133  * Frame bias.
134  */
135 
136     gal_bi00 ( &dpsibi, &depsbi, &dra0 ) ;
137 
138 /*
139  * Precession angles (Lieske et al. 1977)
140  */
141 
142     psia77  =           ( 5038.7784  +
143                         (   -1.07259 +
144                         (   -0.001147 ) * t ) * t ) * t * GAL_AS2R ;
145 
146     oma77   = EPS0 + (  (    0.05127 +
147                         (   -0.007726 ) * t ) * t ) * t * GAL_AS2R ;
148 
149     chia    =           (   10.5526  +
150                         (   -2.38064 +
151                         (   -0.001125 ) * t ) * t ) * t * GAL_AS2R ;
152 
153 /*
154  * Apply IAU 2000 precession corrections.
155  */
156 
157     gal_pr00 ( date1, date2, &dpsipr, &depspr ) ;
158     psia = psia77 + dpsipr ;
159     oma  = oma77  + depspr ;
160 
161 /*
162  * Frame bias matrix: GCRS to J2000.
163  */
164 
165     gal_ir ( rb ) ;
166     gal_rz ( dra0, rb ) ;
167     gal_ry ( dpsibi * sin ( EPS0 ), rb ) ;
168     gal_rx ( -depsbi, rb ) ;
169 
170 /*
171  * Precession matrix: J2000 to mean of date.
172  */
173 
174     gal_ir ( rp ) ;
175     gal_rx ( EPS0, rp ) ;
176     gal_rz ( -psia, rp ) ;
177     gal_rx ( -oma, rp ) ;
178     gal_rz ( chia, rp ) ;
179 
180 /*
181  * Bias-precession matrix: GCRS to mean of date.
182  */
183 
184     gal_rxr ( rp, rb, rbp ) ;
185 
186 /*
187  *  Finished.
188  */
189 
190 }
191 
192 /*
193  *  gal - General Astrodynamics Library
194  *  Copyright (C) 2008 Paul C. L. Willmott
195  *
196  *  This program is free software; you can redistribute it and/or modify
197  *  it under the terms of the GNU General Public License as published by
198  *  the Free Software Foundation; either version 2 of the License, or
199  *  (at your option) any later version.
200  *
201  *  This program is distributed in the hope that it will be useful,
202  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
203  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
204  *  GNU General Public License for more details.
205  *
206  *  You should have received a copy of the GNU General Public License along
207  *  with this program; if not, write to the Free Software Foundation, Inc.,
208  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
209  *
210  *  Contact:
211  *
212  *  Paul Willmott
213  *  vp9mu@amsat.org
214  */
215