Coverage Report

Created: 2026-09-04 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.1/src/star/h2fk5.rs
Line
Count
Source
1
use crate::astro::{pvstar, starpv};
2
use crate::star::fk5hip;
3
use crate::vm::{pmp, pxp, rxp, trxp};
4
5
/// Transform Hipparcos star data into the FK5 (J2000.0) system.
6
///
7
/// Status:  support function.
8
///
9
/// Given (all Hipparcos, epoch J2000.0):
10
///    rh      f64    RA (radians)
11
///    dh      f64    Dec (radians)
12
///    drh     f64    proper motion in RA (dRA/dt, rad/Jyear)
13
///    ddh     f64    proper motion in Dec (dDec/dt, rad/Jyear)
14
///    pxh     f64    parallax (arcsec)
15
///    rvh     f64    radial velocity (km/s, positive = receding)
16
///
17
/// Returned (all FK5, equinox J2000.0, epoch J2000.0):
18
///    r5      f64    RA (radians)
19
///    d5      f64    Dec (radians)
20
///    dr5     f64    proper motion in RA (dRA/dt, rad/Jyear)
21
///    dd5     f64    proper motion in Dec (dDec/dt, rad/Jyear)
22
///    px5     f64    parallax (arcsec)
23
///    rv5     f64    radial velocity (km/s, positive = receding)
24
///
25
/// Notes:
26
///
27
/// 1) This function transforms Hipparcos star positions and proper
28
///    motions into FK5 J2000.0.
29
///
30
/// 2) The proper motions in RA are dRA/dt rather than
31
///    cos(Dec)*dRA/dt, and are per year rather than per century.
32
///
33
/// 3) The FK5 to Hipparcos transformation is modeled as a pure
34
///    rotation and spin;  zonal errors in the FK5 catalog are not
35
///    taken into account.
36
///
37
/// 4) See also fk52h, fk5hz, hfk5z.
38
///
39
/// Called:
40
///    starpv    star catalog data to space motion pv-vector
41
///    fk5hip    FK5 to Hipparcos rotation and spin
42
///    rv2m      r-vector to r-matrix
43
///    rxp       product of r-matrix and p-vector
44
///    trxp      product of transpose of r-matrix and p-vector
45
///    pxp       vector product of two p-vectors
46
///    pmp       p-vector minus p-vector
47
///    pvstar    space motion pv-vector to star catalog data
48
///
49
/// Reference:
50
///    F.Mignard & M.Froeschle, Astron.Astrophys., 354, 732-739 (2000).
51
0
pub fn h2fk5(
52
0
    rh: f64,
53
0
    dh: f64,
54
0
    drh: f64,
55
0
    ddh: f64,
56
0
    pxh: f64,
57
0
    rvh: f64,
58
0
) -> (f64, f64, f64, f64, f64, f64) {
59
0
    let mut pv5 = [[0.0; 3]; 2];
60
0
    let mut sh = [0.0; 3];
61
62
    /* Hipparcos barycentric position/velocity pv-vector (normalized). */
63
0
    let (pvh, _) = starpv(rh, dh, drh, ddh, pxh, rvh);
64
65
    /* FK5 to Hipparcos orientation matrix and spin vector. */
66
0
    let (r5h, mut s5h) = fk5hip();
67
68
    /* Make spin units per day instead of per year. */
69
0
    for val in s5h.iter_mut() {
70
0
        *val /= 365.25;
71
0
    }
72
73
    /* Orient the spin into the Hipparcos system. */
74
0
    rxp(&r5h, &s5h, &mut sh);
75
76
    /* De-orient the Hipparcos position into the FK5 system. */
77
0
    trxp(&r5h, &pvh[0], &mut pv5[0]);
78
79
    /* Apply spin to the position giving an extra space motion component. */
80
0
    let wxp = pxp(&pvh[0], &sh);
81
82
    /* Subtract this component from the Hipparcos space motion. */
83
0
    let vv = pmp(&pvh[1], &wxp);
84
85
    /* De-orient the Hipparcos space motion into the FK5 system. */
86
0
    trxp(&r5h, &vv, &mut pv5[1]);
87
88
    /* FK5 pv-vector to spherical. */
89
0
    let res = pvstar(&pv5).unwrap();
90
0
    let r5 = res[0];
91
0
    let d5 = res[1];
92
0
    let dr5 = res[2];
93
0
    let dd5 = res[3];
94
0
    let px5 = res[4];
95
0
    let rv5 = res[5];
96
97
0
    (r5, d5, dr5, dd5, px5, rv5)
98
0
}