1 /*
2  *  - - - - - - - - -
3  *   g a l _ p n 0 6
4  *  - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *  Precession-nutation, IAU 2006 model:  a multi-purpose routine,
11  *  supporting classical (equinox-based) use directly and CIO-based use
12  *  indirectly.
13  *
14  *  This routine is an independent translation of a FORTRAN routine
15  *  that is part of IAU's SOFA software collection.
16  *
17  *  Status:
18  *
19  *     support routine.
20  *
21  *  Given:
22  *
23  *     date1,date2         d        TT as a 2-part Julian Date (Note 1)
24  *     dpsi,deps           d        nutation (Note 2)
25  *
26  *  Returned:
27  *
28  *     *epsa               d        mean obliquity (Note 3)
29  *     rb               d[3][3]     frame bias matrix (Note 4)
30  *     rp               d[3][3]     precession matrix (Note 5)
31  *     rbp              d[3][3]     bias-precession matrix (Note 6)
32  *     rn               d[3][3]     nutation matrix (Note 7)
33  *     rbpn             d[3][3]     GCRS-to-true matrix (Note 8)
34  *
35  *  Notes:
36  *
37  *  1) The TT date date1+date2 is a Julian Date, apportioned in any
38  *     convenient way between the two arguments.  For example,
39  *     JD(TT)=2450123.7 could be expressed in any of these ways,
40  *     among others:
41  *
42  *            date1         date2
43  *
44  *         2450123.7          0.0        (JD method)
45  *         2451545.0      -1421.3        (J2000 method)
46  *         2400000.5      50123.2        (MJD method)
47  *         2450123.5          0.2        (date & time method)
48  *
49  *     The JD method is the most natural and convenient to use in
50  *     cases where the loss of several decimal digits of resolution
51  *     is acceptable.  The J2000 method is best matched to the way
52  *     the argument is handled internally and will deliver the
53  *     optimum resolution.  The MJD method and the date & time methods
54  *     are both good compromises between resolution and convenience.
55  *
56  *  2) The caller is responsible for providing the nutation components;
57  *     they are in longitude and obliquity, in radians and are with
58  *     respect to the equinox and ecliptic of date.  For high-accuracy
59  *     applications, free core nutation should be included as well as
60  *     any other relevant corrections to the position of the CIP.
61  *
62  *  3) The returned mean obliquity is consistent with the IAU 2006
63  *     precession.
64  *
65  *  4) The matrix rb transforms vectors from GCRS to mean J2000 by
66  *     applying frame bias.
67  *
68  *  5) The matrix rp transforms vectors from mean J2000 to mean of date
69  *     by applying precession.
70  *
71  *  6) The matrix rbp transforms vectors from GCRS to mean of date by
72  *     applying frame bias then precession.  It is the product rp x rb.
73  *
74  *  7) The matrix rn transforms vectors from mean of date to true of date
75  *     by applying the nutation (luni-solar + planetary).
76  *
77  *  8) The matrix rbpn transforms vectors from GCRS to true of date
78  *     (CIP/equinox).  It is the product rn x rbp, applying frame bias,
79  *     precession and nutation in that order.
80  *
81  *  9) The X,Y,Z coordinates of the IAU 2006/2000A Celestial Intermediate
82  *     Pole are elements [0-2][2] of the matrix rbpn.
83  *
84  *  Called:
85  *
86  *     gal_pfw06          bias-precession F-W angles, IAU 2006
87  *     gal_fw2m           F-W angles to r-matrix
88  *     gal_tr             transpose r-matrix
89  *     gal_rxr            product of two r-matrices
90  *
91  *  References:
92  *
93  *     Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
94  *
95  *     Wallace, P.T. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
96  *
97  *  This revision:
98  *
99  *     2006 December 5 ( c version 2008 February 4 )
100  *
101  *
102  *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
103  *
104  *-----------------------------------------------------------------------
105  */
106 
107 #include "gal_const.h"
108 #include "gal_pn06.h"
109 #include "gal_pfw06.h"
110 #include "gal_fw2m.h"
111 #include "gal_tr.h"
112 #include "gal_rxr.h"
113 
114 void
gal_pn06(double date1,double date2,double dpsi,double deps,double * epsa,double rb[3][3],double rp[3][3],double rbp[3][3],double rn[3][3],double rbpn[3][3])115 gal_pn06
116  (
117     double date1,
118     double date2,
119     double dpsi,
120     double deps,
121     double *epsa,
122     double rb[3][3],
123     double rp[3][3],
124     double rbp[3][3],
125     double rn[3][3],
126     double rbpn[3][3]
127  )
128 {
129 
130     double gamb, phib, psib, eps, rt[3][3] ;
131 
132 /*
133  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134  */
135 
136 /*
137  * Bias-precession Fukushima-Williams angles of J2000 = frame bias.
138  */
139 
140     gal_pfw06 ( GAL_MJD0, GAL_MJ2000, &gamb, &phib, &psib, &eps ) ;
141 
142 /*
143  * B matrix.
144  */
145 
146     gal_fw2m ( gamb, phib, psib, eps, rb ) ;
147 
148 /*
149  * Bias-precession Fukushima-Williams angles of date.
150  */
151 
152     gal_pfw06 ( date1, date2, &gamb, &phib, &psib, &eps ) ;
153 
154 /*
155  * Bias-precession matrix.
156  */
157 
158     gal_fw2m ( gamb, phib, psib, eps, rbp ) ;
159 
160 /*
161  * Solve for precession matrix.
162  */
163 
164     gal_tr ( rb, rt ) ;
165     gal_rxr ( rbp, rt, rp ) ;
166 
167 /*
168  * Equinox-based bias-precession-nutation matrix.
169  */
170 
171     gal_fw2m ( gamb, phib, psib + dpsi, eps + deps, rbpn ) ;
172 
173 /*
174  * Solve for nutation matrix.
175  */
176 
177     gal_tr ( rbp, rt ) ;
178     gal_rxr ( rbpn, rt, rn ) ;
179 
180 /*
181  * Obliquity, mean of date.
182  */
183 
184     *epsa = eps ;
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