1 /* cke01.f -- translated by f2c (version 19980913).
2 You must link the resulting object file with the libraries:
3 -lf2c -lm (in that order)
4 */
5
6 #include "f2c.h"
7
8 /* $Procedure CKE01 ( CK evaluate pointing record, data type 1 ) */
cke01_(logical * needav,doublereal * record,doublereal * cmat,doublereal * av,doublereal * clkout)9 /* Subroutine */ int cke01_(logical *needav, doublereal *record, doublereal *
10 cmat, doublereal *av, doublereal *clkout)
11 {
12 extern /* Subroutine */ int chkin_(char *, ftnlen), chkout_(char *,
13 ftnlen);
14 extern logical return_(void);
15 extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
16
17 /* $ Abstract */
18
19 /* Evaluate a pointing record returned by CKR01 from a CK data type 1 */
20 /* segment. Return the C-matrix and optionally the angular velocity */
21 /* vector associated with the time CLKOUT. */
22
23 /* $ Disclaimer */
24
25 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
26 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
27 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
28 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
29 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
30 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
31 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
32 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
33 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
34 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
35
36 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
37 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
38 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
39 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
40 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
41 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
42
43 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
44 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
45 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
46 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
47
48 /* $ Required_Reading */
49
50 /* CK */
51 /* DAF */
52 /* ROTATION */
53
54 /* $ Keywords */
55
56 /* POINTING */
57
58 /* $ Declarations */
59 /* $ Brief_I/O */
60
61 /* Variable I/O Description */
62 /* -------- --- -------------------------------------------------- */
63 /* NEEDAV I True if angular velocity vector is required. */
64 /* RECORD I Data type 1 pointing record. */
65 /* CMAT O C-matrix. */
66 /* AV O Angular velocity vector. */
67 /* CLKOUT O Output spacecraft clock time. */
68
69 /* $ Detailed_Input */
70
71 /* NEEDAV is true when angular velocity data is requested. */
72
73 /* RECORD is a set of double precision numbers returned by CKR01 */
74 /* that contain sufficient information from a data type */
75 /* 1 pointing segment to evaluate the C-matrix and */
76 /* possibly the angular velocity vector (if NEEDAV is */
77 /* true) for a particular instance. */
78
79 /* The contents of RECORD are as follows: */
80
81 /* RECORD( 1 ) = CLKOUT */
82
83 /* RECORD( 2 ) = q0 */
84 /* RECORD( 3 ) = q1 */
85 /* RECORD( 4 ) = q2 */
86 /* RECORD( 5 ) = q3 */
87
88 /* RECORD( 6 ) = Av1 ] */
89 /* RECORD( 7 ) = Av2 |-- Optional */
90 /* RECORD( 8 ) = Av3 ] */
91
92
93 /* The quantities q0 - q3 represent a quaternion. */
94 /* The quantities Av1, Av2, and Av3 represent the angular */
95 /* velocity vector. */
96
97 /* CLKOUT is the encoded spacecraft clock time */
98 /* associated with the quaternion and, optionally, the */
99 /* angular velocity vector. */
100
101 /* $ Detailed_Output */
102
103 /* CMAT is a rotation matrix that transforms the components of */
104 /* of a vector expressed in the reference frame given in */
105 /* the segment to components expressed in the instrument */
106 /* fixed frame at time CLKOUT. */
107
108 /* Thus, if a vector v has components x, y, z in the */
109 /* reference frame, then v has components x', y', z' in */
110 /* the instrument fixed frame at time CLKOUT: */
111
112 /* [ x' ] [ ] [ x ] */
113 /* | y' | = | CMAT | | y | */
114 /* [ z' ] [ ] [ z ] */
115
116 /* If the x', y', z' components are known, use the */
117 /* transpose of the C-matrix to determine x, y, z as */
118 /* follows. */
119
120 /* [ x ] [ ]T [ x' ] */
121 /* | y | = | CMAT | | y' | */
122 /* [ z ] [ ] [ z' ] */
123 /* (Transpose of CMAT) */
124
125 /* AV is the angular velocity vector. This is returned only */
126 /* if it has been requested, as indicated by NEEDAV. In */
127 /* other words, if NEEDAV is true, the angular velocity */
128 /* portion of RECORD must be present. */
129
130 /* The angular velocity vector is the vector whose */
131 /* direction gives the right-handed axis about which */
132 /* the reference frame tied to the instrument is */
133 /* instantaneously rotating at time CLKOUT. */
134
135 /* The angular velocity vector is returned in component */
136 /* form */
137
138 /* AV = [ AV1 , AV2 , AV3 ] */
139
140 /* which is in terms of the reference coordinate frame */
141 /* specified in the segment descriptor. */
142
143 /* The magnitude of AV is the magnitude of the instantane- */
144 /* ous velocity of the rotation, in radians per second. */
145
146 /* CLKOUT The encoded spacecraft clock time associated with the */
147 /* returned C-matrix and, optionally, the returned angular */
148 /* velocity vector. */
149
150
151 /* $ Parameters */
152
153 /* None. */
154
155 /* $ Exceptions */
156
157 /* 1) No checking is done to determine whether RECORD is a valid */
158 /* record. */
159
160 /* 2) If NEEDAV is true, then RECORD is assumed to contain angular */
161 /* velocity data. No checking is performed to verify this */
162 /* assumption. */
163
164 /* $ Files */
165
166 /* None. */
167
168 /* $ Particulars */
169
170 /* For a detailed description of the structure of a type 1 pointing */
171 /* segment, see the CK Required Reading file. */
172
173 /* The only real work done by CKE01 is to convert the pointing */
174 /* portion of the record from quaternion form to C-matrix form. */
175
176 /* The angular velocity vector will only be returned if it has been */
177 /* requested. In other words, if NEEDAV is true, the routine will */
178 /* expect the angular velocity component of the record to be present. */
179
180 /* $ Examples */
181
182 /* A call to a CKEnn routine is almost always preceded by a call to */
183 /* the corresponding CKRnn routine, which gets the logical record */
184 /* that CKEnn evaluates. */
185
186 /* The following code fragment searches through a file represented */
187 /* by HANDLE for all segments applicable to the Voyager 2 wide angle */
188 /* camera, for a particular spacecraft clock time, which have data */
189 /* type 1. It then evaluates the pointing for that epoch and prints */
190 /* the result. */
191
192 /* C */
193 /* C - Get the spacecraft clock time. Must encode it for use */
194 /* C in the C-kernel. */
195 /* C */
196 /* C - Set the time tolerance high to catch anything close to */
197 /* C the input time. */
198 /* C */
199 /* C - We don't need angular velocity data. */
200 /* C */
201
202 /* SC = -32 */
203 /* INST = -32002 */
204 /* TOL = 1000.D0 */
205 /* NEEDAV = .FALSE. */
206 /* DTYPE = 1 */
207 /* C */
208 /* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
209 /* C */
210 /* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
211 /* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
212 /* C */
213 /* C Convert the input request time to ticks. */
214 /* C */
215 /* WRITE (*,*) 'Enter spacecraft clock time string:' */
216 /* READ (*,FMT='(A)') SCLKCH */
217 /* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
218
219 /* C */
220 /* C Search from the beginning through all segments. */
221 /* C */
222 /* CALL DAFBFS ( HANDLE ) */
223 /* CALL DAFFNA ( SFND ) */
224
225 /* DO WHILE ( SFND ) */
226
227 /* CALL DAFGN ( IDENT ) */
228 /* CALL DAFGS ( DESCR ) */
229 /* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
230
231 /* IF ( INST .EQ. ICD( 1 ) */
232 /* . DTYPE .EQ. ICD( 3 ) */
233 /* . .AND. SCLKDP + TOL .GE. DCD( 1 ) */
234 /* . .AND. SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
235
236 /* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
237 /* . RECORD, FOUND ) */
238
239 /* IF ( FOUND ) THEN */
240
241 /* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
242
243 /* WRITE (*,*) 'Segment descriptor and identifier:' */
244 /* WRITE (*,*) DCD, ICD */
245 /* WRITE (*,*) IDENT */
246
247 /* WRITE (*,*) 'C-matrix:' */
248 /* WRITE (*,*) CMAT */
249
250 /* END IF */
251
252 /* END IF */
253
254 /* CALL DAFFNA ( SFND ) */
255
256 /* END DO */
257
258 /* $ Restrictions */
259
260 /* None. */
261
262 /* $ Literature_References */
263
264 /* 1) None. */
265
266 /* $ Author_and_Institution */
267
268 /* J.E. McLean (JPL) */
269 /* M.J. Spencer (JPL) */
270 /* R.E. Thurman (JPL) */
271 /* I.M. Underwood (JPL) */
272
273 /* $ Version */
274
275 /* - SPICELIB Version 1.2.1, 22-AUG-2006 (EDW) */
276
277 /* Replaced header references to LDPOOL with references */
278 /* to FURNSH. */
279
280 /* - SPICELIB Version 1.2.0, 14-NOV-1995 (WLT) */
281
282 /* Changed "inertial frame" to simply reference frame to */
283 /* reflect new capabilities of the SPICE system. */
284
285 /* - SPICELIB Version 1.1.1, 10-MAR-1992 (WLT) */
286
287 /* Comment section for permuted index source lines was added */
288 /* following the header. */
289
290 /* - SPICELIB Version 1.1.0, 30-AUG-1991 (MJS) (JML) */
291
292 /* 1) Previously, in the standard SPICE error handling, the */
293 /* logical function RETURN was not written as a function; */
294 /* it is now written as a function. */
295
296 /* 2) The example program was changed so that the tolerance */
297 /* and data type are used in selecting which segments to read. */
298
299 /* 3) It was specified that the angular velocity vector */
300 /* gives the right-handed axis about which the instrument */
301 /* frame rotates. */
302
303 /* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
304
305 /* The example program was corrected so that the input */
306 /* instrument code was tested against ICD(1) instead of */
307 /* ICD(3). */
308
309 /* - SPICELIB Version 1.0.0, 07-SEP-1990 (RET) (IMU) */
310
311 /* -& */
312 /* $ Index_Entries */
313
314 /* evaluate ck type_1 pointing data record */
315
316 /* -& */
317 /* $ Revisions */
318
319 /* - SPICELIB Version 1.2.0, 14-NOV-1995 (WLT) */
320
321 /* Changed "inertial frame" to simply reference frame to */
322 /* reflect new capabilities of the SPICE system. */
323
324 /* This change affects only documentation not code. */
325
326 /* - SPICELIB Version 1.1.0, 30-AUG-1991 (MJS) (JML) */
327
328 /* 1) In the standard SPICE error handling, the line: */
329
330 /* IF ( RETURN ) THEN */
331
332 /* was changed to */
333
334 /* IF ( RETURN() ) THEN */
335
336 /* 2) The example program was changed so that the tolerance */
337 /* and data type are used in selecting which segments to read. */
338
339 /* 3) It was specified that the angular velocity vector */
340 /* gives the right-handed axis about which the instrument */
341 /* frame rotates. */
342
343 /* - SPICELIB Version 1.0.1, 02-NOV-1990 (JML) */
344
345 /* 1) The example program was corrected so that the input */
346 /* instrument code was tested against ICD(1) instead of */
347 /* ICD(3). */
348 /* 2) SCLK was removed from the Required Reading section. */
349
350 /* - Beta Version 1.1.0, 29-AUG-1990 (MJS) (JEM) */
351
352 /* The following changes were made as a result of the */
353 /* NAIF CK Code and Documentation Review: */
354
355 /* 1) The argument SCLK was removed from the calling sequence. */
356 /* 2) Header was updated. */
357 /* 3) The call to the routine QUAT2M_3 was replaced by a call to */
358 /* the routine Q2M. */
359
360 /* - Beta Version 1.0.0, 18-MAY-1990 (RET) (IMU) */
361
362 /* -& */
363
364 /* SPICELIB functions */
365
366
367 /* Standard SPICE error handling. */
368
369 if (return_()) {
370 return 0;
371 } else {
372 chkin_("CKE01", (ftnlen)5);
373 }
374
375 /* Dissect the record. */
376
377 *clkout = record[0];
378 q2m_(&record[1], cmat);
379 if (*needav) {
380 av[0] = record[5];
381 av[1] = record[6];
382 av[2] = record[7];
383 }
384 chkout_("CKE01", (ftnlen)5);
385 return 0;
386 } /* cke01_ */
387
388