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/astro/atciqn.rs
Line
Count
Source
1
use crate::vm::{anp, c2s, rxp};
2
3
use super::{IauAstrom, IauLdBody, ab, ldn, pmpx};
4
5
///  Quick ICRS −> CIRS, multiple deflections
6
///
7
///  Quick ICRS, epoch J2000.0, to CIRS transformation, given precomputed
8
///  star-independent astrometry parameters plus a list of light-
9
///  deflecting bodies.
10
///
11
///  Use of this function is appropriate when efficiency is important and
12
///  where many star positions are to be transformed for one date.  The
13
///  star-independent parameters can be obtained by calling one of the
14
///  functions iauApci[13], iauApcg[13], iauApco[13] or iauApcs[13].
15
///
16
///
17
///  If the only light-deflecting body to be taken into account is the
18
///  Sun, the iauAtciq function can be used instead.  If in addition the
19
///  parallax and proper motions are zero, the iauAtciqz function can be
20
///  used.
21
///
22
///  This function is part of the International Astronomical Union's
23
///  SOFA (Standards of Fundamental Astronomy) software collection.
24
///
25
///  Status:  support function.
26
///
27
///  Given:
28
///     rc,dc  double       ICRS RA,Dec at J2000.0 (radians)
29
///     pr     double       RA proper motion (radians/year, Note 3)
30
///     pd     double       Dec proper motion (radians/year)
31
///     px     double       parallax (arcsec)
32
///     rv     double       radial velocity (km/s, +ve if receding)
33
///     astrom iauASTROM*   star-independent astrometry parameters:
34
///      pmt    double       PM time interval (SSB, Julian years)
35
///      eb     double[3]    SSB to observer (vector, au)
36
///      eh     double[3]    Sun to observer (unit vector)
37
///      em     double       distance from Sun to observer (au)
38
///      v      double[3]    barycentric observer velocity (vector, c)
39
///      bm1    double       sqrt(1-|v|^2): reciprocal of Lorenz factor
40
///      bpn    double[3][3] bias-precession-nutation matrix
41
///      along  double       longitude + s' (radians)
42
///      xpl    double       polar motion xp wrt local meridian (radians)
43
///      ypl    double       polar motion yp wrt local meridian (radians)
44
///      sphi   double       sine of geodetic latitude
45
///      cphi   double       cosine of geodetic latitude
46
///      diurab double       magnitude of diurnal aberration vector
47
///      eral   double       "local" Earth rotation angle (radians)
48
///      refa   double       refraction constant A (radians)
49
///      refb   double       refraction constant B (radians)
50
///     n      int          number of bodies (Note 3)
51
///     b      iauLDBODY[n] data for each of the n bodies (Notes 3,4):
52
///      bm     double       mass of the body (solar masses, Note 5)
53
///      dl     double       deflection limiter (Note 6)
54
///      pv     [2][3]       barycentric PV of the body (au, au/day)
55
///
56
///  Returned:
57
///     ri,di   double    CIRS RA,Dec (radians)
58
///
59
///  Notes:
60
///
61
///  1) Star data for an epoch other than J2000.0 (for example from the
62
///     Hipparcos catalog, which has an epoch of J1991.25) will require a
63
///     preliminary call to iauPmsafe before use.
64
///
65
///  2) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
66
///
67
///  3) The struct b contains n entries, one for each body to be
68
///     considered.  If n = 0, no gravitational light deflection will be
69
///     applied, not even for the Sun.
70
///
71
///  4) The struct b should include an entry for the Sun as well as for
72
///     any planet or other body to be taken into account.  The entries
73
///     should be in the order in which the light passes the body.
74
///
75
///  5) In the entry in the b struct for body i, the mass parameter
76
///     b[i].bm can, as required, be adjusted in order to allow for such
77
///     effects as quadrupole field.
78
///
79
///  6) The deflection limiter parameter b[i].dl is phi^2/2, where phi is
80
///     the angular separation (in radians) between star and body at
81
///     which limiting is applied.  As phi shrinks below the chosen
82
///     threshold, the deflection is artificially reduced, reaching zero
83
///     for phi = 0.   Example values suitable for a terrestrial
84
///     observer, together with masses, are as follows:
85
///
86
///        body i     b[i].bm        b[i].dl
87
///
88
///        Sun        1.0            6e-6
89
///        Jupiter    0.00095435     3e-9
90
///        Saturn     0.00028574     3e-10
91
///
92
///  7) For efficiency, validation of the contents of the b array is
93
///     omitted.  The supplied masses must be greater than zero, the
94
///     position and velocity vectors must be right, and the deflection
95
///     limiter greater than zero.
96
///
97
///  Called:
98
///     iauPmpx      proper motion and parallax
99
///     iauLdn       light deflection by n bodies
100
///     iauAb        stellar aberration
101
///     iauRxp       product of r-matrix and pv-vector
102
///     iauC2s       p-vector to spherical
103
///     iauAnp       normalize angle into range 0 to 2pi
104
0
pub fn atciqn(
105
0
    rc: f64,
106
0
    dc: f64,
107
0
    pr: f64,
108
0
    pd: f64,
109
0
    px: f64,
110
0
    rv: f64,
111
0
    astrom: &mut IauAstrom,
112
0
    n: i32,
113
0
    b: &[IauLdBody],
114
0
) -> (f64, f64) {
115
    /* Proper motion and parallax, giving BCRS coordinate direction. */
116
0
    let pco = pmpx(rc, dc, pr, pd, px, rv, astrom.pmt, astrom.eb);
117
118
    /* Light deflection, giving BCRS natural direction. */
119
0
    let pnat = ldn(n, b, &astrom.eb, &pco);
120
121
    /* Aberration, giving GCRS proper direction. */
122
0
    let ppr = ab(&pnat, &astrom.v, astrom.em, astrom.bm1);
123
124
    /* Bias-precession-nutation, giving CIRS proper direction. */
125
0
    let pi = &mut [0.0; 3];
126
0
    rxp(&astrom.bpn, &ppr, pi);
127
128
    /* CIRS RA,Dec. */
129
0
    let (w, di) = c2s(pi);
130
0
    let ri = anp(w);
131
132
0
    (ri, di)
133
0
}