Coverage Report

Created: 2026-10-28 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.2/src/pnp/pn06.rs
Line
Count
Source
1
use crate::consts::{DJM00, DJM0};
2
use crate::vm::{rxr, tr};
3
4
use super::{fw2m, pfw06};
5
6
///  Precession-nutation, IAU 2006 model:  a multi-purpose function,
7
///  supporting classical (equinox-based) use directly and CIO-based use
8
///  indirectly.
9
///
10
///  This function is part of the International Astronomical Union's
11
///  SOFA (Standards of Fundamental Astronomy) software collection.
12
///
13
///  Status:  support function.
14
///
15
///  Given:
16
///     date1,date2  double          TT as a 2-part Julian Date (Note 1)
17
///     dpsi,deps    double          nutation (Note 2)
18
///
19
///  Returned (function value):
20
///     (epsa, rb, rp, rbp, rn, rbpn) (f64, [[f64; 3]; 3], [[f64; 3]; 3], [[f64; 3]; 3], [[f64; 3]; 3], [[f64; 3]; 3])
21
///
22
///     epsa         mean obliquity (Note 3)
23
///     rb           frame bias matrix (Note 4)
24
///     rp           precession matrix (Note 5)
25
///     rbp          bias-precession matrix (Note 6)
26
///     rn           nutation matrix (Note 7)
27
///     rbpn         GCRS-to-true matrix (Notes 8,9)
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
///      ```text
37
///             date1          date2
38
///
39
///          2450123.7           0.0       (JD method)
40
///          2451545.0       -1421.3       (J2000 method)
41
///          2400000.5       50123.2       (MJD method)
42
///          2450123.5           0.2       (date & time method)
43
///      ```
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
47
///      is acceptable.  The J2000 method is best matched to the way
48
///      the argument is handled internally and will deliver the
49
///      optimum resolution.  The MJD method and the date & time methods
50
///      are both good compromises between resolution and convenience.
51
///
52
///  2)  The caller is responsible for providing the nutation components;
53
///      they are in longitude and obliquity, in radians and are with
54
///      respect to the equinox and ecliptic of date.  For high-accuracy
55
///      applications, free core nutation should be included as well as
56
///      any other relevant corrections to the position of the CIP.
57
///
58
///  3)  The returned mean obliquity is consistent with the IAU 2006
59
///      precession.
60
///
61
///  4)  The matrix rb transforms vectors from GCRS to J2000.0 mean
62
///      equator and equinox by applying frame bias.
63
///
64
///  5)  The matrix rp transforms vectors from J2000.0 mean equator and
65
///      equinox to mean equator and equinox of date by applying
66
///      precession.
67
///
68
///  6)  The matrix rbp transforms vectors from GCRS to mean equator and
69
///      equinox of date by applying frame bias then precession.  It is
70
///      the product rp x rb.
71
///
72
///  7)  The matrix rn transforms vectors from mean equator and equinox
73
///      of date to true equator and equinox of date by applying the
74
///      nutation (luni-solar + planetary).
75
///
76
///  8)  The matrix rbpn transforms vectors from GCRS to true equator and
77
///      equinox of date.  It is the product rn x rbp, applying frame
78
///      bias, precession and nutation in that order.
79
///
80
///  9)  The X,Y,Z coordinates of the Celestial Intermediate Pole are
81
///      elements (3,1-3) of the GCRS-to-true matrix, i.e. rbpn[2][0-2].
82
///
83
///  Called:
84
///     iauPfw06     bias-precession F-W angles, IAU 2006
85
///     iauFw2m      F-W angles to r-matrix
86
///     iauCr        copy r-matrix
87
///     iauTr        transpose r-matrix
88
///     iauRxr       product of two r-matrices
89
///
90
///  References:
91
///
92
///     Capitaine, N. & Wallace, P.T., 2006, Astron.Astrophys. 450, 855
93
///
94
///     Wallace, P.T. & Capitaine, N., 2006, Astron.Astrophys. 459, 981
95
0
pub fn pn06(
96
0
    date1: f64,
97
0
    date2: f64,
98
0
    dpsi: f64,
99
0
    deps: f64,
100
0
) -> (
101
0
    f64,
102
0
    [[f64; 3]; 3],
103
0
    [[f64; 3]; 3],
104
0
    [[f64; 3]; 3],
105
0
    [[f64; 3]; 3],
106
0
    [[f64; 3]; 3],
107
0
) {
108
0
    let mut rp = [[0.0; 3]; 3];
109
0
    let mut rn = [[0.0; 3]; 3];
110
0
    let mut rt = [[0.0; 3]; 3];
111
112
    /* Bias-precession Fukushima-Williams angles of J2000.0 = frame bias. */
113
0
    let (gamb, phib, psib, eps) = pfw06(DJM0, DJM00);
114
115
    /* B matrix. */
116
0
    let rb = fw2m(gamb, phib, psib, eps);
117
118
    /* Bias-precession Fukushima-Williams angles of date. */
119
0
    let (gamb_date, phib_date, psib_date, eps_date) = pfw06(date1, date2);
120
121
    /* Bias-precession matrix. */
122
0
    let rbp = fw2m(gamb_date, phib_date, psib_date, eps_date);
123
124
    /* Solve for precession matrix. */
125
0
    tr(&rb, &mut rt);
126
0
    rxr(&rbp, &rt, &mut rp);
127
128
    /* Equinox-based bias-precession-nutation matrix. */
129
0
    let rbpn = fw2m(gamb_date, phib_date, psib_date + dpsi, eps_date + deps);
130
131
    /* Solve for nutation matrix. */
132
0
    tr(&rbp, &mut rt);
133
0
    rxr(&rbpn, &rt, &mut rn);
134
135
    /* Obliquity, mean of date. */
136
0
    (eps_date, rb, rp, rbp, rn, rbpn)
137
0
}