1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::utils::*;
use crate::vector_matrix::{init::ir::*, build_rotations::{rz::rz, ry::ry}};
/// Form the celestial to intermediate-frame-of-date matrix given the CIP
/// X,Y and the CIO locator s.
///
/// Given:
/// * x,y Celestial Intermediate Pole (Note 1)
/// * s the CIO locator s (Note 2)
///
/// Returned:
/// * rc2i celestial-to-intermediate matrix (Note 3)
///
/// # Notes:
///
/// 1) The Celestial Intermediate Pole coordinates are the x,y
/// components of the unit vector in the Geocentric Celestial
/// Reference System.
///
/// 2) The CIO locator s (in radians) positions the Celestial
/// Intermediate Origin on the equator of the CIP.
///
/// 3) The matrix rc2i is the first stage in the transformation from
/// celestial to terrestrial coordinates:
///
/// [TRS] = RPOM * R_3(ERA) * rc2i * [CRS]
///
/// = RC2T * [CRS]
///
/// where [CRS] is a vector in the Geocentric Celestial Reference
/// System and [TRS] is a vector in the International Terrestrial
/// Reference System (see IERS Conventions 2003), ERA is the Earth
/// Rotation Angle and RPOM is the polar motion matrix.
///
/// # Called:
/// * ir initialize r-matrix to identity
/// * rz rotate around Z-axis
/// * ry rotate around Y-axis
///
/// # Reference:
/// * McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
/// IERS Technical Note No. 32, BKG (2004)
///
/// This revision: 2021 May 11
pub fn c2ixys(x: f64, y: f64, s: f64, rc2i: &mut [[f64; 3]; 3])
{
/* Obtain the spherical angles E and d. */
let r2 = x*x + y*y;
let e = if r2 > 0.0 {atan2(y, x) }else{ 0.0 };
let d = atan(sqrt(r2 / (1.0 - r2)));
/* Form the matrix. */
ir(rc2i);
rz(e, rc2i);
ry(d, rc2i);
rz(-(e+s), rc2i);
/* Finished. */
}