/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/pnp/nut00b.rs
Line | Count | Source |
1 | | use crate::consts::{D2PI, DAS2R, DJ00, DJC, DMAS2R, TURNAS}; |
2 | | use std::ops::Rem; |
3 | | |
4 | | struct Coeff { |
5 | | nl: i32, |
6 | | nlp: i32, |
7 | | nf: i32, |
8 | | nd: i32, |
9 | | nom: i32, /* coefficients of l,l',F,D,Om */ |
10 | | ps: f64, |
11 | | pst: f64, |
12 | | pc: f64, /* longitude sin, t*sin, cos coefficients */ |
13 | | ec: f64, |
14 | | ect: f64, |
15 | | es: f64, /* obliquity cos, t*cos, sin coefficients */ |
16 | | } |
17 | | |
18 | | impl Coeff { |
19 | 0 | const fn new( |
20 | 0 | nl: i32, |
21 | 0 | nlp: i32, |
22 | 0 | nf: i32, |
23 | 0 | nd: i32, |
24 | 0 | nom: i32, |
25 | 0 | ps: f64, |
26 | 0 | pst: f64, |
27 | 0 | pc: f64, |
28 | 0 | ec: f64, |
29 | 0 | ect: f64, |
30 | 0 | es: f64, |
31 | 0 | ) -> Self { |
32 | 0 | Coeff { |
33 | 0 | nl, |
34 | 0 | nlp, |
35 | 0 | nf, |
36 | 0 | nd, |
37 | 0 | nom, |
38 | 0 | ps, |
39 | 0 | pst, |
40 | 0 | pc, |
41 | 0 | ec, |
42 | 0 | ect, |
43 | 0 | es, |
44 | 0 | } |
45 | 0 | } |
46 | | } |
47 | | |
48 | | const X: [Coeff; 77] = [ |
49 | | /* 1-10 */ |
50 | | Coeff::new( |
51 | | 0, |
52 | | 0, |
53 | | 0, |
54 | | 0, |
55 | | 1, |
56 | | -172064161.0, |
57 | | -174666.0, |
58 | | 33386.0, |
59 | | 92052331.0, |
60 | | 9086.0, |
61 | | 15377.0, |
62 | | ), |
63 | | Coeff::new( |
64 | | 0, |
65 | | 0, |
66 | | 2, |
67 | | -2, |
68 | | 2, |
69 | | -13170906.0, |
70 | | -1675.0, |
71 | | -13696.0, |
72 | | 5730336.0, |
73 | | -3015.0, |
74 | | -4587.0, |
75 | | ), |
76 | | Coeff::new( |
77 | | 0, 0, 2, 0, 2, -2276413.0, -234.0, 2796.0, 978459.0, -485.0, 1374.0, |
78 | | ), |
79 | | Coeff::new( |
80 | | 0, 0, 0, 0, 2, 2074554.0, 207.0, -698.0, -897492.0, 470.0, -291.0, |
81 | | ), |
82 | | Coeff::new( |
83 | | 0, 1, 0, 0, 0, 1475877.0, -3633.0, 11817.0, 73871.0, -184.0, -1924.0, |
84 | | ), |
85 | | Coeff::new( |
86 | | 0, 1, 2, -2, 2, -516821.0, 1226.0, -524.0, 224386.0, -677.0, -174.0, |
87 | | ), |
88 | | Coeff::new(1, 0, 0, 0, 0, 711159.0, 73.0, -872.0, -6750.0, 0.0, 358.0), |
89 | | Coeff::new( |
90 | | 0, 0, 2, 0, 1, -387298.0, -367.0, 380.0, 200728.0, 18.0, 318.0, |
91 | | ), |
92 | | Coeff::new( |
93 | | 1, 0, 2, 0, 2, -301461.0, -36.0, 816.0, 129025.0, -63.0, 367.0, |
94 | | ), |
95 | | Coeff::new( |
96 | | 0, -1, 2, -2, 2, 215829.0, -494.0, 111.0, -95929.0, 299.0, 132.0, |
97 | | ), |
98 | | /* 11-20 */ |
99 | | Coeff::new(0, 0, 2, -2, 1, 128227.0, 137.0, 181.0, -68982.0, -9.0, 39.0), |
100 | | Coeff::new(-1, 0, 2, 0, 2, 123457.0, 11.0, 19.0, -53311.0, 32.0, -4.0), |
101 | | Coeff::new(-1, 0, 0, 2, 0, 156994.0, 10.0, -168.0, -1235.0, 0.0, 82.0), |
102 | | Coeff::new(1, 0, 0, 0, 1, 63110.0, 63.0, 27.0, -33228.0, 0.0, -9.0), |
103 | | Coeff::new(-1, 0, 0, 0, 1, -57976.0, -63.0, -189.0, 31429.0, 0.0, -75.0), |
104 | | Coeff::new(-1, 0, 2, 2, 2, -59641.0, -11.0, 149.0, 25543.0, -11.0, 66.0), |
105 | | Coeff::new(1, 0, 2, 0, 1, -51613.0, -42.0, 129.0, 26366.0, 0.0, 78.0), |
106 | | Coeff::new(-2, 0, 2, 0, 1, 45893.0, 50.0, 31.0, -24236.0, -10.0, 20.0), |
107 | | Coeff::new(0, 0, 0, 2, 0, 63384.0, 11.0, -150.0, -1220.0, 0.0, 29.0), |
108 | | Coeff::new(0, 0, 2, 2, 2, -38571.0, -1.0, 158.0, 16452.0, -11.0, 68.0), |
109 | | /* 21-30 */ |
110 | | Coeff::new(0, -2, 2, -2, 2, 32481.0, 0.0, 0.0, -13870.0, 0.0, 0.0), |
111 | | Coeff::new(-2, 0, 0, 2, 0, -47722.0, 0.0, -18.0, 477.0, 0.0, -25.0), |
112 | | Coeff::new(2, 0, 2, 0, 2, -31046.0, -1.0, 131.0, 13238.0, -11.0, 59.0), |
113 | | Coeff::new(1, 0, 2, -2, 2, 28593.0, 0.0, -1.0, -12338.0, 10.0, -3.0), |
114 | | Coeff::new(-1, 0, 2, 0, 1, 20441.0, 21.0, 10.0, -10758.0, 0.0, -3.0), |
115 | | Coeff::new(2, 0, 0, 0, 0, 29243.0, 0.0, -74.0, -609.0, 0.0, 13.0), |
116 | | Coeff::new(0, 0, 2, 0, 0, 25887.0, 0.0, -66.0, -550.0, 0.0, 11.0), |
117 | | Coeff::new(0, 1, 0, 0, 1, -14053.0, -25.0, 79.0, 8551.0, -2.0, -45.0), |
118 | | Coeff::new(-1, 0, 0, 2, 1, 15164.0, 10.0, 11.0, -8001.0, 0.0, -1.0), |
119 | | Coeff::new(0, 2, 2, -2, 2, -15794.0, 72.0, -16.0, 6850.0, -42.0, -5.0), |
120 | | /* 31-40 */ |
121 | | Coeff::new(0, 0, -2, 2, 0, 21783.0, 0.0, 13.0, -167.0, 0.0, 13.0), |
122 | | Coeff::new(1, 0, 0, -2, 1, -12873.0, -10.0, -37.0, 6953.0, 0.0, -14.0), |
123 | | Coeff::new(0, -1, 0, 0, 1, -12654.0, 11.0, 63.0, 6415.0, 0.0, 26.0), |
124 | | Coeff::new(-1, 0, 2, 2, 1, -10204.0, 0.0, 25.0, 5222.0, 0.0, 15.0), |
125 | | Coeff::new(0, 2, 0, 0, 0, 16707.0, -85.0, -10.0, 168.0, -1.0, 10.0), |
126 | | Coeff::new(1, 0, 2, 2, 2, -7691.0, 0.0, 44.0, 3268.0, 0.0, 19.0), |
127 | | Coeff::new(-2, 0, 2, 0, 0, -11024.0, 0.0, -14.0, 104.0, 0.0, 2.0), |
128 | | Coeff::new(0, 1, 2, 0, 2, 7566.0, -21.0, -11.0, -3250.0, 0.0, -5.0), |
129 | | Coeff::new(0, 0, 2, 2, 1, -6637.0, -11.0, 25.0, 3353.0, 0.0, 14.0), |
130 | | Coeff::new(0, -1, 2, 0, 2, -7141.0, 21.0, 8.0, 3070.0, 0.0, 4.0), |
131 | | /* 41-50 */ |
132 | | Coeff::new(0, 0, 0, 2, 1, -6302.0, -11.0, 2.0, 3272.0, 0.0, 4.0), |
133 | | Coeff::new(1, 0, 2, -2, 1, 5800.0, 10.0, 2.0, -3045.0, 0.0, -1.0), |
134 | | Coeff::new(2, 0, 2, -2, 2, 6443.0, 0.0, -7.0, -2768.0, 0.0, -4.0), |
135 | | Coeff::new(-2, 0, 0, 2, 1, -5774.0, -11.0, -15.0, 3041.0, 0.0, -5.0), |
136 | | Coeff::new(2, 0, 2, 0, 1, -5350.0, 0.0, 21.0, 2695.0, 0.0, 12.0), |
137 | | Coeff::new(0, -1, 2, -2, 1, -4752.0, -11.0, -3.0, 2719.0, 0.0, -3.0), |
138 | | Coeff::new(0, 0, 0, -2, 1, -4940.0, -11.0, -21.0, 2720.0, 0.0, -9.0), |
139 | | Coeff::new(-1, -1, 0, 2, 0, 7350.0, 0.0, -8.0, -51.0, 0.0, 4.0), |
140 | | Coeff::new(2, 0, 0, -2, 1, 4065.0, 0.0, 6.0, -2206.0, 0.0, 1.0), |
141 | | Coeff::new(1, 0, 0, 2, 0, 6579.0, 0.0, -24.0, -199.0, 0.0, 2.0), |
142 | | /* 51-60 */ |
143 | | Coeff::new(0, 1, 2, -2, 1, 3579.0, 0.0, 5.0, -1900.0, 0.0, 1.0), |
144 | | Coeff::new(1, -1, 0, 0, 0, 4725.0, 0.0, -6.0, -41.0, 0.0, 3.0), |
145 | | Coeff::new(-2, 0, 2, 0, 2, -3075.0, 0.0, -2.0, 1313.0, 0.0, -1.0), |
146 | | Coeff::new(3, 0, 2, 0, 2, -2904.0, 0.0, 15.0, 1233.0, 0.0, 7.0), |
147 | | Coeff::new(0, -1, 0, 2, 0, 4348.0, 0.0, -10.0, -81.0, 0.0, 2.0), |
148 | | Coeff::new(1, -1, 2, 0, 2, -2878.0, 0.0, 8.0, 1232.0, 0.0, 4.0), |
149 | | Coeff::new(0, 0, 0, 1, 0, -4230.0, 0.0, 5.0, -20.0, 0.0, -2.0), |
150 | | Coeff::new(-1, -1, 2, 2, 2, -2819.0, 0.0, 7.0, 1207.0, 0.0, 3.0), |
151 | | Coeff::new(-1, 0, 2, 0, 0, -4056.0, 0.0, 5.0, 40.0, 0.0, -2.0), |
152 | | Coeff::new(0, -1, 2, 2, 2, -2647.0, 0.0, 11.0, 1129.0, 0.0, 5.0), |
153 | | /* 61-70 */ |
154 | | Coeff::new(-2, 0, 0, 0, 1, -2294.0, 0.0, -10.0, 1266.0, 0.0, -4.0), |
155 | | Coeff::new(1, 1, 2, 0, 2, 2481.0, 0.0, -7.0, -1062.0, 0.0, -3.0), |
156 | | Coeff::new(2, 0, 0, 0, 1, 2179.0, 0.0, -2.0, -1129.0, 0.0, -2.0), |
157 | | Coeff::new(-1, 1, 0, 1, 0, 3276.0, 0.0, 1.0, -9.0, 0.0, 0.0), |
158 | | Coeff::new(1, 1, 0, 0, 0, -3389.0, 0.0, 5.0, 35.0, 0.0, -2.0), |
159 | | Coeff::new(1, 0, 2, 0, 0, 3339.0, 0.0, -13.0, -107.0, 0.0, 1.0), |
160 | | Coeff::new(-1, 0, 2, -2, 1, -1987.0, 0.0, -6.0, 1073.0, 0.0, -2.0), |
161 | | Coeff::new(1, 0, 0, 0, 2, -1981.0, 0.0, 0.0, 854.0, 0.0, 0.0), |
162 | | Coeff::new(-1, 0, 0, 1, 0, 4026.0, 0.0, -353.0, -553.0, 0.0, -139.0), |
163 | | Coeff::new(0, 0, 2, 1, 2, 1660.0, 0.0, -5.0, -710.0, 0.0, -2.0), |
164 | | /* 71-77 */ |
165 | | Coeff::new(-1, 0, 2, 4, 2, -1521.0, 0.0, 9.0, 647.0, 0.0, 4.0), |
166 | | Coeff::new(-1, 1, 0, 1, 1, 1314.0, 0.0, 0.0, -700.0, 0.0, 0.0), |
167 | | Coeff::new(0, -2, 2, -2, 1, -1283.0, 0.0, 0.0, 672.0, 0.0, 0.0), |
168 | | Coeff::new(1, 0, 2, 2, 1, -1331.0, 0.0, 8.0, 663.0, 0.0, 4.0), |
169 | | Coeff::new(-2, 0, 2, 2, 2, 1383.0, 0.0, -2.0, -594.0, 0.0, -2.0), |
170 | | Coeff::new(-1, 0, 0, 0, 2, 1405.0, 0.0, 4.0, -610.0, 0.0, 2.0), |
171 | | Coeff::new(1, 1, 2, -2, 2, 1290.0, 0.0, 0.0, -556.0, 0.0, 0.0), |
172 | | ]; |
173 | | |
174 | | /// nutation, IAU 2000B |
175 | 0 | pub fn nut00b(date1: f64, date2: f64) -> (f64, f64) { |
176 | | /* Units of 0.1 microarcsecond to radians */ |
177 | | const U2R: f64 = DAS2R / 1e7; |
178 | | |
179 | | /* ---------------------------------------- */ |
180 | | /* Fixed offsets in lieu of planetary terms */ |
181 | | /* ---------------------------------------- */ |
182 | | |
183 | | const DPPLAN: f64 = -0.135 * DMAS2R; |
184 | | const DEPLAN: f64 = 0.388 * DMAS2R; |
185 | | |
186 | | /* Interval between fundamental epoch J2000.0 and given date (JC). */ |
187 | 0 | let t = ((date1 - DJ00) + date2) / DJC; |
188 | | |
189 | | /* --------------------*/ |
190 | | /* LUNI-SOLAR NUTATION */ |
191 | | /* --------------------*/ |
192 | | |
193 | | /* Fundamental (Delaunay) arguments from Simon et al. (1994) */ |
194 | | |
195 | | /* Mean anomaly of the Moon. */ |
196 | 0 | let el = (485868.249036 + (1717915923.2178) * t).rem(TURNAS) * DAS2R; |
197 | | |
198 | | /* Mean anomaly of the Sun. */ |
199 | 0 | let elp = (1287104.79305 + (129596581.0481) * t).rem(TURNAS) * DAS2R; |
200 | | |
201 | | /* Mean argument of the latitude of the Moon. */ |
202 | 0 | let f = (335779.526232 + (1739527262.8478) * t).rem(TURNAS) * DAS2R; |
203 | | |
204 | | /* Mean elongation of the Moon from the Sun. */ |
205 | 0 | let d = (1072260.70369 + (1602961601.2090) * t).rem(TURNAS) * DAS2R; |
206 | | |
207 | | /* Mean longitude of the ascending node of the Moon. */ |
208 | 0 | let om = (450160.398036 + (-6962890.5431) * t).rem(TURNAS) * DAS2R; |
209 | | |
210 | | /* Initialize the nutation values. */ |
211 | 0 | let mut dp = 0.0; |
212 | 0 | let mut de = 0.0; |
213 | | |
214 | | /* Summation of luni-solar nutation series (smallest terms first). */ |
215 | 0 | for i in (0..X.len()).rev() { |
216 | 0 | /* Argument and functions. */ |
217 | 0 | let arg = (X[i].nl as f64 * el |
218 | 0 | + X[i].nlp as f64 * elp |
219 | 0 | + X[i].nf as f64 * f |
220 | 0 | + X[i].nd as f64 * d |
221 | 0 | + X[i].nom as f64 * om) |
222 | 0 | .rem(D2PI); |
223 | 0 | let sarg = arg.sin(); |
224 | 0 | let carg = arg.cos(); |
225 | 0 |
|
226 | 0 | /* Term. */ |
227 | 0 | dp += (X[i].ps + X[i].pst * t) * sarg + X[i].pc * carg; |
228 | 0 | de += (X[i].ec + X[i].ect * t) * carg + X[i].es * sarg; |
229 | 0 | } |
230 | | |
231 | | /* Convert from 0.1 microarcsec units to radians. */ |
232 | 0 | let dpsils = dp * U2R; |
233 | 0 | let depsls = de * U2R; |
234 | | |
235 | | /* ------------------------------*/ |
236 | | /* IN LIEU OF PLANETARY NUTATION */ |
237 | | /* ------------------------------*/ |
238 | | |
239 | | /* Fixed offset to correct for missing terms in truncated series. */ |
240 | 0 | let dpsipl = DPPLAN; |
241 | 0 | let depspl = DEPLAN; |
242 | | |
243 | | /* --------*/ |
244 | | /* RESULTS */ |
245 | | /* --------*/ |
246 | | |
247 | | /* Add luni-solar and planetary components. */ |
248 | 0 | let dpsi = dpsils + dpsipl; |
249 | 0 | let deps = depsls + depspl; |
250 | | |
251 | 0 | (dpsi, deps) |
252 | 0 | } |