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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
/// Inertial reference frame transformation
///
/// Return the matrix that transforms vectors from one specified
/// inertial reference frame to another.
///
/// # Required Reading
///
/// * [SPK](crate::required_reading::spk)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// REFA I Name of reference frame to transform vectors FROM.
/// REFB I Name of reference frame to transform vectors TO.
/// ROTAB O REFA-to-REFB transformation matrix.
/// ```
///
/// # Detailed Input
///
/// ```text
/// REFA,
/// REFB are the names of two inertial reference frames. Any names
/// accepted by the routine IRFNUM may be used. See
/// $Particulars for a list of some of the more commonly used
/// inertial reference frame names.
/// ```
///
/// # Detailed Output
///
/// ```text
/// ROTAB is a rotation matrix that transforms the
/// coordinates of a vector V relative to the
/// reference frame specified by REFA to the
/// coordinates of V relative to the reference frame
/// specified by REFB. The transformation is carried
/// out by the matrix multiplication
///
/// V = ROTAB * V.
/// ```
///
/// # Exceptions
///
/// ```text
/// 1) If either of the input reference frame names is invalid, an
/// error is signaled by a routine in the call tree of this
/// routine.
/// ```
///
/// # Particulars
///
/// ```text
/// Normally applications should call the more general, higher level
/// routine PXFORM instead of this routine.
///
/// This routine is a macro that replaces the code fragment
///
/// CALL IRFNUM ( REFA, CODEA )
/// CALL IRFNUM ( REFB, CODEB )
/// CALL IRFROT ( CODEA, CODEB, ROTAB )
///
///
/// Among the reference frame names accepted by IRFNUM are:
///
/// 'J2000'
/// 'B1950'
/// 'FK4'
/// 'DE-96'
/// 'DE-102'
/// 'DE-108'
/// 'DE-111'
/// 'DE-114'
/// 'DE-118'
/// 'DE-122'
/// 'DE-125'
/// 'DE-130'
/// 'DE-200'
/// 'DE-202'
/// 'GALACTIC'
///
/// See the SPICELIB routine GHGIRF for details.
/// ```
///
/// # Examples
///
/// ```text
/// 1) Transform a vector V1950 from the B1950 to the J2000
/// reference frame.
///
/// C
/// C Ask IRFTRN for the matrix that transforms vectors
/// C from the B1950 to the J2000 reference frame.
/// C
/// CALL IRFTRN ( 'B1950', 'J2000', TRANS )
///
/// C
/// C Now transform V1950 to the J2000 reference frame.
/// C
/// CALL MXV ( TRANS, V1950, V2000 )
/// ```
///
/// # Author and Institution
///
/// ```text
/// N.J. Bachman (JPL)
/// J. Diaz del Rio (ODC Space)
/// W.L. Taber (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 1.1.0, 20-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 1.0.2, 28-SEP-2004 (NJB)
///
/// Corrected comment in code example in header. Made other minor
/// updates to header.
///
/// - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
///
/// Comment section for permuted index source lines was added
/// following the header.
///
/// - SPICELIB Version 1.0.0, 30-AUG-1991 (NJB)
/// ```
pub fn irftrn(
ctx: &mut SpiceContext,
refa: &str,
refb: &str,
rotab: &mut [[f64; 3]; 3],
) -> crate::Result<()> {
IRFTRN(
refa.as_bytes(),
refb.as_bytes(),
rotab.as_flattened_mut(),
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure IRFTRN ( Inertial reference frame transformation )
pub fn IRFTRN(
REFA: &[u8],
REFB: &[u8],
ROTAB: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut ROTAB = DummyArrayMut2D::new(ROTAB, 1..=3, 1..=3);
let mut CODEA: i32 = 0;
let mut CODEB: i32 = 0;
//
// SPICELIB functions
//
//
// Local variables
//
//
// Standard SPICE error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"IRFTRN", ctx)?;
}
//
// Encode the reference frame names, and find the transformation
// matrix.
//
IRFNUM(REFA, &mut CODEA, ctx);
IRFNUM(REFB, &mut CODEB, ctx);
IRFROT(CODEA, CODEB, ROTAB.as_slice_mut(), ctx)?;
CHKOUT(b"IRFTRN", ctx)?;
Ok(())
}