1 /* cke02.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 /* Table of constant values */
9
10 static integer c__4 = 4;
11
12 /* $Procedure CKE02 ( C-kernel, evaluate pointing record, data type 2 ) */
cke02_(logical * needav,doublereal * record,doublereal * cmat,doublereal * av,doublereal * clkout)13 /* Subroutine */ int cke02_(logical *needav, doublereal *record, doublereal *
14 cmat, doublereal *av, doublereal *clkout)
15 {
16 doublereal time, quat[4];
17 extern /* Subroutine */ int vequ_(doublereal *, doublereal *), mxmt_(
18 doublereal *, doublereal *, doublereal *);
19 doublereal cbase[9] /* was [3][3] */, angle;
20 extern /* Subroutine */ int chkin_(char *, ftnlen), vequg_(doublereal *,
21 integer *, doublereal *);
22 extern doublereal vnorm_(doublereal *);
23 extern /* Subroutine */ int axisar_(doublereal *, doublereal *,
24 doublereal *);
25 doublereal avtemp[3];
26 extern /* Subroutine */ int chkout_(char *, ftnlen);
27 extern logical return_(void);
28 extern /* Subroutine */ int q2m_(doublereal *, doublereal *);
29 doublereal rot[9] /* was [3][3] */;
30
31 /* $ Abstract */
32
33 /* Evaluate a pointing record returned by CKR02 from a CK data type 2 */
34 /* segment. Return the C-matrix and angular velocity vector associated */
35 /* with the time CLKOUT. */
36
37 /* $ Disclaimer */
38
39 /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
40 /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
41 /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
42 /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
43 /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
44 /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
45 /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
46 /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
47 /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
48 /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
49
50 /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
51 /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
52 /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
53 /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
54 /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
55 /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
56
57 /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
58 /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
59 /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
60 /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
61
62 /* $ Required_Reading */
63
64 /* CK */
65 /* ROTATION */
66
67 /* $ Keywords */
68
69 /* POINTING */
70
71 /* $ Declarations */
72 /* $ Brief_I/O */
73
74 /* Variable I/O Description */
75 /* -------- --- -------------------------------------------------- */
76 /* NEEDAV I True if angular velocity is requested. */
77 /* RECORD I Data type 2 pointing record. */
78 /* CMAT O C-matrix. */
79 /* AV O Angular velocity vector. */
80 /* CLKOUT O SCLK associated with C-matrix. */
81
82 /* $ Detailed_Input */
83
84 /* NEEDAV is true if angular velocity is requested. */
85
86 /* RECORD is a set of double precision numbers returned by CKR02 */
87 /* that contain sufficient information from a data type */
88 /* 2 pointing segment to evaluate the C-matrix and the */
89 /* angular velocity vector for a particular instance. */
90
91 /* The contents of RECORD are as follows: */
92
93 /* RECORD( 1 ) = start SCLKDP of interval */
94
95 /* RECORD( 2 ) = SCLK for which pointing was found */
96
97 /* RECORD( 3 ) = seconds / tick rate */
98
99 /* RECORD( 4 ) = q0 */
100 /* RECORD( 5 ) = q1 */
101 /* RECORD( 6 ) = q2 */
102 /* RECORD( 7 ) = q3 */
103
104 /* RECORD( 8 ) = av1 */
105 /* RECORD( 9 ) = av2 */
106 /* RECORD( 10 ) = av3 */
107
108 /* The quantities q0 - q3 are the components of the */
109 /* quaternion that represents the C - matrix associated */
110 /* with the start of the interval. The quantities av1, */
111 /* av2, and av3 are the components of the angular velocity */
112 /* vector. */
113
114 /* $ Detailed_Output */
115
116
117 /* CMAT is a rotation matrix that transforms the components */
118 /* of a vector expressed in the inertial frame given in */
119 /* the segment to components expressed in the instrument */
120 /* fixed frame at the returned time. */
121
122 /* Thus, if a vector v has components x, y, z in the */
123 /* inertial frame, then v has components x', y', z' in the */
124 /* instrument fixed frame where: */
125
126 /* [ x' ] [ ] [ x ] */
127 /* | y' | = | CMAT | | y | */
128 /* [ z' ] [ ] [ z ] */
129
130 /* If the x', y', z' components are known, use the */
131 /* transpose of the C-matrix to determine x, y, z as */
132 /* follows. */
133
134 /* [ x ] [ ]T [ x' ] */
135 /* | y | = | CMAT | | y' | */
136 /* [ z ] [ ] [ z' ] */
137 /* (Transpose of CMAT) */
138
139 /* AV is the angular velocity vector. The angular velocity */
140 /* contained in RECORD is returned only if NEEDAV is true. */
141
142 /* The direction of the angular velocity vector gives */
143 /* the right-handed axis about which the instrument fixed */
144 /* reference frame is rotating. The magnitude of AV is */
145 /* the magnitude of the instantaneous velocity of the */
146 /* rotation, in radians per second. */
147
148 /* The angular velocity vector is returned in component */
149 /* form */
150
151 /* AV = [ AV1 , AV2 , AV3 ] */
152
153 /* which is in terms of the inertial coordinate frame */
154 /* specified in the segment descriptor. */
155
156 /* CLKOUT is the encoded SCLK associated with the returned */
157 /* C-matrix and angular velocity vector. */
158
159 /* $ Parameters */
160
161 /* None. */
162
163 /* $ Exceptions */
164
165 /* 1) No checking is done to determine whether RECORD is valid. */
166
167 /* $ Files */
168
169 /* None. */
170
171 /* $ Particulars */
172
173 /* For a detailed description of the structure of a type 2 pointing */
174 /* segment, see the CK Required Reading. */
175
176 /* Pointing data in a type 2 segment consists of intervals during */
177 /* which the orientation of the spacecraft structure can be described */
178 /* by an initial C-matrix and a constant angular velocity vector. */
179 /* From the information contained in the pointing record returned by */
180 /* CKR02, this subroutine calculates and returns the C-matrix */
181 /* associated with the time returned by CKR02. It also returns the */
182 /* angular velocity vector contained in the pointing record. */
183
184 /* $ Examples */
185
186 /* A call to a CKEnn routine is almost always preceded by a call to */
187 /* the corresponding CKRnn routine, which gets the logical record */
188 /* that CKEnn evaluates. */
189
190 /* The following code fragment searches through a file (represented */
191 /* by HANDLE) for all segments applicable to the Voyager 2 wide angle */
192 /* camera, for a particular spacecraft clock time, that are of data */
193 /* types 1 or 2. It then evaluates the pointing for that epoch and */
194 /* prints the result. */
195
196
197 /* SC = -32 */
198 /* INST = -32002 */
199 /* C */
200 /* C Load the Voyager 2 spacecraft clock kernel and the C-kernel. */
201 /* C */
202 /* CALL FURNSH ( 'VGR_SCLK.TSC' ) */
203 /* CALL DAFOPR ( 'VGR2_CK.BC', HANDLE ) */
204
205 /* C */
206 /* C Get the spacecraft clock time. Must encode it for use */
207 /* C in the C-kernel. */
208 /* C */
209
210 /* WRITE (*,*) 'Enter spacecraft clock time string:' */
211 /* READ (*,FMT='(A)') SCLKCH */
212 /* CALL SCENCD ( SC, SCLKCH, SCLKDP ) */
213
214 /* C */
215 /* C Search from the beginning through all segments. */
216 /* C */
217 /* CALL DAFBFS ( HANDLE ) */
218 /* CALL DAFFNA ( SFND ) */
219
220 /* DO WHILE ( SFND ) */
221
222 /* CALL DAFGN ( IDENT ) */
223 /* CALL DAFGS ( DESCR ) */
224 /* CALL DAFUS ( DESCR, 2, 6, DCD, ICD ) */
225
226 /* IF ( INST .EQ. ICD( 1 ) .AND. */
227 /* . SCLKDP + TOL .GE. DCD( 1 ) .AND. */
228 /* . SCLKDP - TOL .LE. DCD( 2 ) ) THEN */
229
230 /* DTYPE = ICD ( 3 ) */
231
232 /* IF ( DTYPE .EQ. 1 ) THEN */
233
234 /* CALL CKR01 ( HANDLE, DESCR, SCLKDP, TOL, NEEDAV, */
235 /* . RECORD, FOUND ) */
236
237 /* IF ( FOUND ) THEN */
238 /* CALL CKE01 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
239 /* END IF */
240
241 /* ELSE IF ( DTYPE .EQ. 2 ) THEN */
242
243 /* CALL CKR02 ( HANDLE, DESCR, SCLKDP, TOL, */
244 /* . RECORD, FOUND ) */
245
246 /* IF ( FOUND ) THEN */
247 /* CALL CKE02 ( NEEDAV, RECORD, CMAT, AV, CLKOUT ) */
248 /* END IF */
249
250 /* END IF */
251
252 /* IF ( FOUND ) THEN */
253
254 /* WRITE (*,*) 'Segment descriptor and identifier:' */
255 /* WRITE (*,*) DCD, ICD */
256 /* WRITE (*,*) IDENT */
257
258 /* WRITE (*,*) 'C-matrix:' */
259 /* WRITE (*,*) CMAT */
260
261 /* END IF */
262
263 /* END IF */
264
265 /* CALL DAFFNA ( SFND ) */
266
267 /* END DO */
268
269 /* $ Restrictions */
270
271 /* None. */
272
273 /* $ Literature_References */
274
275 /* None. */
276
277 /* $ Author_and_Institution */
278
279 /* J.M. Lynch (JPL) */
280 /* W.L. Taber (JPL) */
281 /* E.D. Wright (JPL) */
282 /* B.V. Semenov (JPL) */
283
284 /* $ Version */
285
286 /* - SPICELIB Version 1.0.3, 31-JAN-2008 (BVS) */
287
288 /* Removed non-standard end-of-declarations marker */
289 /* 'C%&END_DECLARATIONS' from comments. */
290
291 /* - SPICELIB Version 1.0.2, 22-AUG-2006 (EDW) */
292
293 /* Replaced references to LDPOOL with references */
294 /* to FURNSH. */
295
296 /* - SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) */
297
298 /* Comment section for permuted index source lines was added */
299 /* following the header. */
300
301 /* - SPICELIB Version 1.0.0, 30-AUG-1991 (JML) */
302
303 /* -& */
304 /* $ Index_Entries */
305
306 /* evaluate ck type_2 pointing data record */
307
308 /* -& */
309
310 /* SPICELIB functions */
311
312
313 /* Local variables */
314
315
316 /* Standard SPICE error handling. */
317
318 if (return_()) {
319 return 0;
320 } else {
321 chkin_("CKE02", (ftnlen)5);
322 }
323
324 /* Copy the returned encoded SCLK time into CLKOUT. */
325
326 *clkout = record[1];
327 /* The quaternion stored in RECORD represents the C - matrix */
328 /* corresponding to the start time of the interval. The angular */
329 /* velocity vector is constant throughout the interval and gives */
330 /* the axis and rate by which the spacecraft is rotating. */
331
332 /* Copy the quaternion and the angular velocity from RECORD. */
333
334 /* RECORD ( 4 ) = q0 */
335 /* RECORD ( 5 ) = q1 */
336 /* RECORD ( 6 ) = q2 */
337 /* RECORD ( 7 ) = q3 */
338
339 /* RECORD ( 8 ) = av1 */
340 /* RECORD ( 9 ) = av2 */
341 /* RECORD ( 10 ) = av3 */
342
343 vequg_(&record[3], &c__4, quat);
344 vequ_(&record[7], avtemp);
345
346 /* Calculate the angle of the rotation. */
347
348 /* RECORD ( 1 ) = The start time of the interval. */
349 /* RECORD ( 2 ) = The time that pointing was returned for. */
350 /* RECORD ( 3 ) = The number of seconds per SCLK tick. */
351
352 time = (record[1] - record[0]) * record[2];
353 angle = time * vnorm_(avtemp);
354
355 /* Construct a matrix which rotates vectors by ANGLE radians about */
356 /* AVTEMP. */
357
358 axisar_(avtemp, &angle, rot);
359
360 /* Convert the quaternion to a C - matrix. */
361
362 q2m_(quat, cbase);
363
364 /* Rotate each of the axis vectors of the spacecraft instrument frame */
365 /* by ANGLE radians about AVTEMP. (AVTEMP is given in the same */
366 /* inertial frame as the C - matrix.) The resulting matrix is the */
367 /* transpose of the requested C - matrix. */
368
369 /* [ ] [ ] T [ ] T */
370 /* [ ROT ] * [ CBASE ] = [ CMAT ] */
371 /* [ ] [ ] [ ] */
372
373 /* OR */
374
375 /* [ ] [ ] T [ ] */
376 /* [ CBASE ] * [ ROT ] = [ CMAT ] */
377 /* [ ] [ ] [ ] */
378
379 mxmt_(cbase, rot, cmat);
380
381 /* Return the angular velocity only if it is requested. */
382
383 if (*needav) {
384 vequ_(avtemp, av);
385 }
386 chkout_("CKE02", (ftnlen)5);
387 return 0;
388 } /* cke02_ */
389
390