Table of contents
rav2xf_c ( Rotation and angular velocity to transform )
void rav2xf_c ( ConstSpiceDouble rot ,
ConstSpiceDouble av ,
SpiceDouble xform  )
Determine a state transformation matrix from a rotation matrix
and the angular velocity of the rotation.
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
rot I Rotation matrix.
av I Angular velocity vector.
xform O State transformation associated with `rot' and `av'.
rot is a rotation matrix that gives the transformation from
some frame FRAME1 to another frame FRAME2.
av is the angular velocity of the transformation.
In other words, if `p' is the position of a fixed
point in FRAME2, then from the point of view of
FRAME1, `p' rotates (in a right handed sense) about
an axis parallel to `av'. Moreover the rate of rotation
in radians per unit time is given by the length of
More formally, the velocity `v' of `p' in FRAME1 is
v = av x ( rot * p )
xform is a state transformation matrix associated
with `rot' and `av'. If `s1' is the state of an object
with respect to FRAME1, then the state `s2' of the
object with respect to FRAME2 is given by
s2 = xform * s1
where "*" denotes Matrix-Vector multiplication.
1) No checks are performed on `rot' to ensure that it is indeed
a rotation matrix.
This routine is essentially a macro routine for converting
a rotation and angular velocity of the rotation to the
equivalent state transformation matrix.
This routine is an inverse of xf2rav_c.
The numerical results shown for this example may differ across
platforms. The results depend on the SPICE kernels used as
input, the compiler and supporting libraries, and the machine
specific arithmetic implementation.
1) The following example program uses ckgpav_c to get C-matrix
and associated angular velocity vector for an image whose
SCLK count (un-encoded character string version) is known.
From that matrix and angular velocity vector, the associated
state transformation matrix is obtained.
Note that we need to load a SCLK kernel to convert from clock
string to "ticks." Although not required for older spacecraft
clocks, most modern spacecraft ones require a leapseconds
kernel to be loaded in addition to a SCLK kernel.
Use the meta-kernel shown below to load the required SPICE
File name: rav2xf_ex1.tm
This meta-kernel is intended to support operation of SPICE
example programs. The kernels shown here should not be
assumed to contain adequate or correct versions of data
required by SPICE-based user applications.
In order for an application to use this meta-kernel, the
kernels referenced here must be present in the user's
current working directory.
The names and contents of the kernels referenced
by this meta-kernel are as follows:
File name Contents
cas00071.tsc CASSINI SCLK
04161_04164ra.bc CASSINI spacecraft
KERNELS_TO_LOAD = ( 'cas00071.tsc'
End of meta-kernel
Example code begins here.
int main( )
Constants for this program.
-- The code for the CASSINI spacecraft clock is -82.
-- The code for CASSINI spacecraft reference frame is
-- Spacecraft clock tolerance is 1.0 seconds. This may
not be an acceptable tolerance for some applications.
It must be converted to "ticks" (units of encoded
SCLK) for input to ckgpav_c.
-- The reference frame we want is J2000.
#define META "rav2xf_ex1.tm"
#define REFFRM "J2000"
#define SCLKCH "1/1465476046.160"
#define SCLTOL "1.0"
#define SCID -82
#define INSTID -82000
SpiceDouble av ;
SpiceDouble cmat ;
SpiceDouble fxmat ;
furnsh_c ( META );
Convert tolerance from CASSINI formatted character
string SCLK to ticks which are units of encoded SCLK.
sctiks_c ( SCID, SCLTOL, &toltik );
ckgpav_c requires encoded spacecraft clock.
scencd_c ( SCID, SCLKCH, &sclkdp );
ckgpav_c ( INSTID, sclkdp, toltik, REFFRM,
cmat, av, &clkout, &found );
Recall that `cmat' and `av' are the rotation and angular
velocity of the transformation from J2000 to the
if ( found )
Display `cmat' and `av'.
printf( "Rotation matrix:\n" );
for ( i = 0; i < 3; i++ )
printf( "%10.6f %9.6f %9.6f\n",
cmat[i], cmat[i], cmat[i] );
printf( "Angular velocity:\n" );
printf( "%20.16f %19.16f %19.16f\n", av, av, av );
Get state transformation from J2000 to the spacecraft
rav2xf_c ( cmat, av, fxmat );
Display the results.
printf( "\n" );
printf( "State transformation matrix:\n" );
for ( i = 0; i < 6; i++ )
printf( "%10.6f %9.6f %9.6f %9.6f %9.6f %9.6f\n",
fxmat[i], fxmat[i], fxmat[i],
fxmat[i], fxmat[i], fxmat[i] );
printf( "No rotation matrix/angular velocity found for %s\n",
return ( 0 );
When this program was executed on a Mac/Intel/cc/64-bit
platform, the output was:
-0.604984 0.796222 -0.005028
-0.784160 -0.596891 -0.169748
-0.138158 -0.098752 0.985475
0.0000032866819065 -0.0000099372638338 0.0000197597699770
State transformation matrix:
-0.604984 0.796222 -0.005028 0.000000 0.000000 0.000000
-0.784160 -0.596891 -0.169748 0.000000 0.000000 0.000000
-0.138158 -0.098752 0.985475 0.000000 0.000000 0.000000
-0.000016 -0.000012 -0.000003 -0.604984 0.796222 -0.005028
0.000013 -0.000015 -0.000010 -0.784160 -0.596891 -0.169748
-0.000008 -0.000006 -0.000002 -0.138158 -0.098752 0.985475
N.J. Bachman (JPL)
J. Diaz del Rio (ODC Space)
W.L. Taber (JPL)
E.D. Wright (JPL)
-CSPICE Version 1.0.2, 16-JUL-2020 (JDR)
Edited the header to comply with NAIF standard. Added complete
code example based on existing example.
Added ROTATION to the required readings.
-CSPICE Version 1.0.1, 12-APR-2007 (EDW)
Edit to abstract.
-CSPICE Version 1.0.0, 18-JUN-1999 (WLT) (NJB)
State transformation to rotation and angular velocity