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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//
// GENERATED FILE
//
use super::*;
use crate::SpiceContext;
use f2rust_std::*;
const ND: i32 = 2;
const NI: i32 = 5;
const NR: i32 = 2;
const NS: i32 = 5;
const NT: i32 = 3;
const FILEN: i32 = 128;
/// PCK, get Euler angles at time from PCK file
///
/// This routine is obsolete. It supports only the type 02 binary
/// PCK format. It is maintained only for backward compatibility
///
/// Return Euler angles and their derivatives and their reference
/// frame, given an input time and body and reference frame from
/// a PCK binary file.
///
/// # Required Reading
///
/// * [NAIF_IDS](crate::required_reading::naif_ids)
/// * [ROTATION](crate::required_reading::rotation)
/// * [TIME](crate::required_reading::time)
/// * [PCK](crate::required_reading::pck)
///
/// # Brief I/O
///
/// ```text
/// VARIABLE I/O DESCRIPTION
/// -------- --- --------------------------------------------------
/// BODY I ID code of body
/// ET I Epoch of transformation
/// FOUND O .TRUE. if ET, BODY found in a PCK file
/// REF O Name of inertial ref. frame of state
/// EULANG O Euler angles and their derivatives.
/// ```
///
/// # Detailed Input
///
/// ```text
/// BODY is the integer ID code of the body for which the
/// state transformation matrix is requested. Bodies
/// are numbered according to the standard NAIF
/// numbering scheme. The numbering scheme is
/// explained in the NAIF_IDS required reading file.
///
/// ET is the epoch at which the state transformation
/// matrix is requested.
/// ```
///
/// # Detailed Output
///
/// ```text
/// FOUND if the Euler angles for the requested time
/// and body are found in a PCK binary file,
/// FOUND is .TRUE. Otherwise, it's false.
///
/// REF is the name of an inertial ref. frame.
/// (See the routine CHGIRF for a full list of names.)
///
/// EULANG is the Euler angles and their derivatives at
/// time ET. The rotation matrix is
/// [ EULANG(3) ] [EULANG(2)] [EULANG(1)]
/// 3 1 3
///
/// and dEULANG(1)/dt = EULANG(4)
/// dEULANG(2)/dt = EULANG(5)
/// dEULANG(3)/dt = EULANG(6)
/// ```
///
/// # Examples
///
/// ```text
/// Here we load a binary PCK files and use PCKEUL to get the
/// Euler angles.
///
/// C
/// C Load binary PCK file.
/// C
/// CALL PCKLOF ('example.pck', HANDLE)
///
/// C Call routine to get Euler angles phi, delta, w.
///
/// CALL PCKEUL ( BODY, ET, FOUND, REF, EULANG )
///
/// The Euler angles and their derivatives are returned
/// in EULANG.
/// ```
///
/// # Restrictions
///
/// ```text
/// 1) A binary PCK kernel must be loaded with PCKLOF before
/// calling this routine.
/// ```
///
/// # Author and Institution
///
/// ```text
/// J. Diaz del Rio (ODC Space)
/// E.D. Wright (JPL)
/// K.S. Zukor (JPL)
/// ```
///
/// # Version
///
/// ```text
/// - SPICELIB Version 2.1.0, 20-AUG-2021 (JDR)
///
/// Added IMPLICIT NONE statement.
///
/// Edited the header to comply with NAIF standard.
///
/// - SPICELIB Version 2.0.1, 03-JAN-2014 (EDW)
///
/// Minor edits to $Procedure; clean trailing whitespace.
/// Removed unneeded $Revisions section.
///
/// - SPICELIB Version 2.0.0, 21-MAR-1995 (KSZ)
///
/// PCKEUL modified to check in. PCKMAT takes
/// over for PCKEUL in many cases. REF now a character.
///
/// - SPICELIB Version 1.1.0, 18-OCT-1994 (KSZ)
///
/// Fixed bug which incorrectly modded DW by two pi.
///
/// - SPICELIB Version 1.0.0, 11-MAR-1994 (KSZ)
/// ```
pub fn pckeul(
ctx: &mut SpiceContext,
body: i32,
et: f64,
found: &mut bool,
ref_: &mut str,
eulang: &mut [f64; 6],
) -> crate::Result<()> {
PCKEUL(
body,
et,
found,
fstr::StrBytes::new(ref_).as_mut(),
eulang,
ctx.raw_context(),
)?;
ctx.handle_errors()?;
Ok(())
}
//$Procedure PCKEUL ( PCK, get Euler angles at time from PCK file )
pub fn PCKEUL(
BODY: i32,
ET: f64,
FOUND: &mut bool,
REF: &mut [u8],
EULANG: &mut [f64],
ctx: &mut Context,
) -> f2rust_std::Result<()> {
let mut EULANG = DummyArrayMut::new(EULANG, 1..=6);
let mut IDENT = [b' '; 40 as usize];
let mut DCD = StackArray::<f64, 2>::new(1..=ND);
let mut DESCR = StackArray::<f64, 5>::new(1..=NS);
let mut RECORD = StackArray::<f64, 130>::new(1..=130);
let mut TYPE: i32 = 0;
let mut HANDLE: i32 = 0;
let mut ICD = StackArray::<i32, 5>::new(1..=NI);
let mut IREF: i32 = 0;
//
// SPICELIB functions
//
//
// Parameters
//
// ND number of double precision components of descriptor
// NI number of integer components of descriptor
// NR component number of reference frame in integer
// portion of descriptor
// NS size of a packed PCK segment descriptor
// NT component number of data type in integer portion
// of descriptor
//
//
// Local Variables
//
//
// Standard SPICE Error handling.
//
if RETURN(ctx) {
return Ok(());
} else {
CHKIN(b"PCKEUL", ctx)?;
}
//
// Get a segment applicable to a specified body and epoch.
//
PCKSFS(
BODY,
ET,
&mut HANDLE,
DESCR.as_slice_mut(),
&mut IDENT,
FOUND,
ctx,
)?;
if *FOUND {
//
// Look at parts of the descriptor.
//
DAFUS(
DESCR.as_slice(),
ND,
NI,
DCD.as_slice_mut(),
ICD.as_slice_mut(),
);
TYPE = ICD[NT];
IREF = ICD[NR];
IRFNAM(IREF, REF, ctx)?;
if (TYPE == 2) {
//
// Read in Chebyshev coefficients from segment.
//
PCKR02(HANDLE, DESCR.as_slice(), ET, RECORD.as_slice_mut(), ctx)?;
//
// Call evaluation routine to get Euler angles
// phi, delta, w.
//
PCKE02(ET, RECORD.as_slice(), EULANG.as_slice_mut(), ctx)?;
} else {
//
// If appropriate data was not found, found is false.
//
*FOUND = false;
}
}
CHKOUT(b"PCKEUL", ctx)?;
Ok(())
}