1 /*
2  *  - - - - - - - - -
3  *   g a l _ p n 0 0
4  *  - - - - - - - - -
5  *
6  *  This routine is part of the General Astrodynamics Library
7  *
8  *  Description:
9  *
10  *  Precession-nutation, IAU 2000 model:  a multi-purpose routine,
11  *  supporting classical (equinox-based) use directly and CIO-based
12  *  use 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 2000
63  *     precession-nutation models.
64  *
65  *  4) The matrix rb transforms vectors from GCRS to J2000 mean equator
66  *     and equinox by applying frame bias.
67  *
68  *  5) The matrix rp transforms vectors from J2000 mean equator and
69  *     equinox to mean equator and equinox of date by applying
70  *     precession.
71  *
72  *  6) The matrix rbp transforms vectors from GCRS to mean equator and
73  *     equinox of date by applying frame bias then precession.  It is the
74  *     product rp x rb.
75  *
76  *  7) The matrix rn transforms vectors from mean equator and equinox of
77  *     date to true equator and equinox of date by applying the nutation
78  *     (luni-solar + planetary).
79  *
80  *  8) The matrix rbpn transforms vectors from GCRS to true equator and
81  *     equinox of date.  It is the product rn x rbp, applying frame bias,
82  *     precession and nutation in that order.
83  *
84  *  Called:
85  *
86  *     gal_pr00           IAU 2000 precession adjustments
87  *     gal_obl80          mean obliquity, IAU 1980
88  *     gal_bp00           frame bias and precession matrices, IAU 2000
89  *     gal_numat          form nutation matrix
90  *     gal_rxr            product of two r-matrices
91  *
92  *  References:
93  *
94  *     Capitaine, N., Chapront, J., Lambert, S. and Wallace, P.,
95  *     "Expressions for the Celestial Intermediate Pole and Celestial
96  *     Ephemeris Origin consistent with the IAU 2000A precession-nutation
97  *     model", Astronomy & Astrophysics, 400, 1145-1154 (2003)
98  *
99  *     n.b. The celestial ephemeris origin (CEO) was renamed "celestial
100  *          intermediate origin" (CIO) by IAU 2006 Resolution 2.
101  *
102  *  This revision:
103  *
104  *     2007 April 11 ( c version 2008 February 4 )
105  *
106  *
107  *  Copyright (C) 2008 Paul C. L. Willmott. See notes at end.
108  *
109  *-----------------------------------------------------------------------
110  */
111 
112 #include "gal_pn00.h"
113 #include "gal_pr00.h"
114 #include "gal_obl80.h"
115 #include "gal_bp00.h"
116 #include "gal_numat.h"
117 #include "gal_rxr.h"
118 
119 void
gal_pn00(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])120 gal_pn00
121  (
122     double date1,
123     double date2,
124     double dpsi,
125     double deps,
126     double *epsa,
127     double rb[3][3],
128     double rp[3][3],
129     double rbp[3][3],
130     double rn[3][3],
131     double rbpn[3][3]
132  )
133 {
134 
135     double dpsipr, depspr ;
136 
137 /*
138  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139  */
140 
141 /*
142  * IAU 2000 precession-rate adjustments.
143  */
144 
145     gal_pr00 ( date1, date2, &dpsipr, &depspr ) ;
146 
147 /*
148  * Mean obliquity, consistent with IAU 2000 precession-nutation.
149  */
150 
151     *epsa = gal_obl80 ( date1, date2 ) + depspr ;
152 
153 /*
154  * Frame bias and precession matrices and their product.
155  */
156 
157     gal_bp00 ( date1, date2, rb, rp, rbp ) ;
158 
159 /*
160  * Nutation matrix.
161  */
162 
163     gal_numat ( *epsa, dpsi, deps, rn ) ;
164 
165 /*
166  * Bias-precession-nutation matrix (classical).
167  */
168 
169     gal_rxr ( rn, rbp, rbpn ) ;
170 
171 /*
172  * Finished.
173  */
174 
175 }
176 
177 /*
178  *  gal - General Astrodynamics Library
179  *  Copyright (C) 2008 Paul C. L. Willmott
180  *
181  *  This program is free software; you can redistribute it and/or modify
182  *  it under the terms of the GNU General Public License as published by
183  *  the Free Software Foundation; either version 2 of the License, or
184  *  (at your option) any later version.
185  *
186  *  This program is distributed in the hope that it will be useful,
187  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
188  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
189  *  GNU General Public License for more details.
190  *
191  *  You should have received a copy of the GNU General Public License along
192  *  with this program; if not, write to the Free Software Foundation, Inc.,
193  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
194  *
195  *  Contact:
196  *
197  *  Paul Willmott
198  *  vp9mu@amsat.org
199  */
200