Skip to main content

sofars/coords/
eceq06.rs

1use crate::coords::ecm06;
2use crate::vm::{anp, anpm, c2s, s2c, trxp};
3
4/// Transformation from ecliptic coordinates (mean equinox and ecliptic
5/// of date) to ICRS RA,Dec, using the IAU 2006 precession model.
6///
7/// Status:  support function.
8///
9/// Given:
10///    date1,date2 f64 TT as a 2-part Julian date (Note 1)
11///    dl,db       f64 ecliptic longitude and latitude (radians)
12///
13/// Returned:
14///    dr,dd       f64 ICRS right ascension and declination (radians)
15///
16/// 1) The TT date date1+date2 is a Julian Date, apportioned in any
17///    convenient way between the two arguments.  For example,
18///    JD(TT)=2450123.7 could be expressed in any of these ways,
19///    among others:
20///
21///           date1          date2
22///
23///        2450123.7           0.0       (JD method)
24///        2451545.0       -1421.3       (J2000 method)
25///        2400000.5       50123.2       (MJD method)
26///        2450123.5           0.2       (date & time method)
27///
28///    The JD method is the most natural and convenient to use in
29///    cases where the loss of several decimal digits of resolution
30///    is acceptable.  The J2000 method is best matched to the way
31///    the argument is handled internally and will deliver the
32///    optimum resolution.  The MJD method and the date & time methods
33///    are both good compromises between resolution and convenience.
34///
35/// 2) No assumptions are made about whether the coordinates represent
36///    starlight and embody astrometric effects such as parallax or
37///    aberration.
38///
39/// 3) The transformation is approximately that from ecliptic longitude
40///    and latitude (mean equinox and ecliptic of date) to mean J2000.0
41///    right ascension and declination, with only frame bias (always
42///    less than 25 mas) to disturb this classical picture.
43pub fn eceq06(date1: f64, date2: f64, dl: f64, db: f64) -> (f64, f64) {
44    let mut v2 = [0.0; 3];
45
46    /* Spherical to Cartesian. */
47    let v1 = s2c(dl, db);
48
49    /* Rotation matrix, ICRS equatorial to ecliptic. */
50    let rm = ecm06(date1, date2);
51
52    /* The transformation from ecliptic to ICRS. */
53    trxp(&rm, &v1, &mut v2);
54
55    /* Cartesian to spherical. */
56    let (a, b) = c2s(&v2);
57
58    /* Express in conventional ranges. */
59    (anp(a), anpm(b))
60}