Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_m2eul

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_M2EUL factors a rotation matrix into a product of
   three rotations about specified coordinate axes.

I/O


   Given:

      r        a 3x3 double precision rotation matrix to factor as a product of
               three rotations about a specified coordinate axes.

               help, r
                  DOUBLE = Array[3,3]

               The angles of these rotations are called "Euler angles."

      axis3,
      axis2,
      axis1    the indices of the rotation axes of the "factor" rotations,
               whose product is `r'.

               help, axis3
                  LONG = Scalar
               help, axis2
                  LONG = Scalar
               help, axis1
                  LONG = Scalar

               `r' is factored as

                  r = [ angle3 ]      [ angle2 ]      [ angle1 ]
                                axis3           axis2           axis1

               The axis numbers must belong to the set {1, 2, 3}.
               The second axis number MUST differ from the first
               and third axis numbers.

   the call:

      cspice_m2eul, r, axis3, axis2, axis1, angle3, angle2, angle1

   returns:

      angle3,
      angle2,
      angle1   a set of double precision Euler angles
               measured where the angle satisfy

                  r = [ angle3 ]      [ angle2 ]      [ angle1 ]
                                axis3           axis2           axis1

               The range of `angle3' and `angle1' is (-pi, pi].

               help, angle3
                  DOUBLE = Scalar
               help, angle2
                  DOUBLE = Scalar
               help, angle1
                  DOUBLE = Scalar

               The range of 'angle2' depends on the exact set of
               axes used for the factorization. For
               factorizations in which the first and third axes
               are the same,

                  r = [R]  [S]  [T]
                         a    b    a

               the range of 'angle2' is [0, pi].

               For factorizations in which the first and third
               axes are different,

                  r = [R]  [S]  [T] ,
                         a    b    c

               the range of angle2 is [-pi/2, pi/2].

               For rotations such that `angle3' and `angle1' are not
               uniquely determined, `angle3' will always be set to
               zero; `angle1' is then uniquely determined.

Parameters


   None.

Examples


   Any numerical results shown for these examples may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) Conversion of instrument pointing from a matrix representation
      to Euler angles:

      Suppose we want to find camera pointing in alpha, delta, and
      kappa, given the inertial-to-camera coordinate transformation

          .-                                                         -.
          |  0.491273796781358  0.508726203218642  0.706999085398824  |
          |                                                           |
          | -0.508726203218642 -0.491273796781358  0.706999085398824  |
          |                                                           |
          |  0.706999085398824 -0.706999085398824  0.017452406437284  |
          `-                                                         -'

      Find angles alpha, delta, kappa such that

         ticam  =  [ kappa ]  [ pi/2 - delta ]  [ pi/2 + alpha ] .
                            3                 1                 3

      Example code begins here.


      PRO m2eul_ex1

         ;;
         ;; Conversion of instrument pointing from a matrix representation
         ;; to Euler angles:
         ;;
         ;; Suppose we want to find camera pointing in alpha, delta, and
         ;; kappa, given the inertial-to-camera coordinate transformation
         ;;

         ticam = [                                                           $
            [  0.491273796781358d,  0.508726203218642d, 0.706999085398824d], $
            [ -0.508726203218642d, -0.491273796781358d, 0.706999085398824d], $
            [  0.706999085398824d, -0.706999085398824d, 0.017452406437284d] ]

         ;;
         ;; We want to find angles alpha, delta, kappa such that
         ;;
         ;;
         ;;   ticam  =  [ kappa ]  [ pi/2 - delta ]  [ pi/2 + alpha ]
         ;;                      3                 1                 3
         ;;
         cspice_m2eul, ticam, 3, 1, 3, kappa, ang2, ang1

         alpha  =  ang1            - cspice_halfpi()
         delta  =  cspice_halfpi() - ang2

         ;;
         ;; Calculate the desired angles. If we wish to make sure that
         ;; alpha, delta, and kappa are in the ranges [0, 2pi),
         ;; [-pi/2, pi/2], and [0, 2pi) respectively, we may add the code
         ;;
         if ( alpha LT 0.d ) then begin
          alpha = alpha + cspice_twopi()
         endif

         if ( kappa LT 0.d ) then begin
            kappa = kappa + cspice_twopi()
         endif


         print, format='(A,F24.14)', 'Alpha (deg): ', cspice_dpr( ) * alpha
         print, format='(A,F24.14)', 'Delta (deg): ', cspice_dpr( ) * delta
         print, format='(A,F24.14)', 'Kappa (deg): ', cspice_dpr( ) * kappa

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Alpha (deg):       315.00000000000000
      Delta (deg):         1.00000000000003
      Kappa (deg):        45.00000000000000


   2) Conversion of instrument pointing angles from a non-J2000,
      not necessarily inertial frame to J2000-relative RA, Dec,
      and Twist.

      Suppose that we have orientation for the CASSINI Narrow Angle
      Camera (NAC) frame expressed as

         [ gamma ]  [ beta ]  [ alpha ]
                  1         2          3

      with respect to the CASSINI spacecraft frame.

      We want to express that orientation with respect to the J2000
      frame as the sequence of rotations

         [ twist ]  [ dec ]  [ ra ] .
                  3        1       3

      Use the meta-kernel shown below to load the required SPICE
      kernels.


         KPL/MK

         File name: m2eul_ex2.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
            ---------                      --------
            naif0010.tls                   Leapseconds
            cas00145.tsc                   Cassini SCLK
            cas_v40.tf                     Cassini frames
            08052_08057ra.bc               Orientation for Cassini

         \begindata

            KERNELS_TO_LOAD = ( 'naif0010.tls'
                                'cas00145.tsc'
                                'cas_v40.tf'
                                '08052_08057ra.bc')

         \begintext

         End of meta-kernel


      Example code begins here.


      PRO m2eul_ex2

         ;;
         ;; Local parameters
         ;;
         META  = 'm2eul_ex2.tm'
         ALPHA =  89.9148d
         BETA  =  -0.03300d
         GAMMA = -90.009796d

         ;;
         ;; Load the kernels.
         ;;
         cspice_furnsh, META

         ;;
         ;; First, we use procedure cspice_eul2m to form the
         ;; transformation from instrument coordinates to
         ;; CASSINI spacecraft frame.
         ;;
         cspice_eul2m, GAMMA * cspice_rpd( ), BETA * cspice_rpd( ),          $
                       ALPHA * cspice_rpd( ), 1, 2, 3, inst2s

         ;;
         ;; Now we compute the transformation from CASSINI
         ;; spacecraft frame to J2000, at a given time.
         ;;
         cspice_str2et, '2008 Feb 25', et
         cspice_pxform, 'CASSINI_SC_COORD', 'J2000', et, s2j

         ;;
         ;; Next, we form the transformation from instrument
         ;; coordinates to J2000 frame.
         ;;
         cspice_mxm, s2j, inst2s, inst2j

         ;;
         ;; Finally, we express `inst2j' using the desired Euler
         ;; angles.
         ;;
         cspice_m2eul, inst2j, 3, 1, 3, twist, ang1, ang2

         ra   =  ang2 - cspice_halfpi( )
         dec  =  cspice_halfpi( ) - ang1

         ;;
         ;; If we wish to make sure that `ra', `dec', and `twist' are in
         ;; the ranges [0, 2pi), [-pi/2, pi/2], and [0, 2pi)
         ;; respectively, we may add the code
         ;;
         if ( ra lt 0.0 ) then begin
            ra = ra + cspice_twopi( )
         endif

         if ( twist lt 0.0 ) then begin
            twist = twist + cspice_twopi( )
         endif

         ;;
         ;; Now `ra', `dec', and `twist' express the instrument pointing
         ;; as RA, Dec, and Twist, relative to the J2000 system.
         ;;
         print, format='(A,F24.14)', 'RA    (deg): ', cspice_dpr( ) * ra
         print, format='(A,F24.14)', 'Dec   (deg): ', cspice_dpr( ) * dec
         print, format='(A,F24.14)', 'Twist (deg): ', cspice_dpr( ) * twist

         ;;
         ;; It's always good form to unload kernels after use,
         ;; particularly in IDL due to data persistence.
         ;;
         cspice_kclear

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      RA    (deg):        83.77802387778848
      Dec   (deg):       -14.92925498590898
      Twist (deg):       294.55732942050986


      Note:  more than one definition of RA, Dec, and Twist is
      extant. Before using this example in an application, check
      that the definition given here is consistent with that used
      in your application.

Particulars


   A word about notation: the symbol

      [ x ]
           i

   indicates a coordinate system rotation of `x' radians about the
   ith coordinate axis. To be specific, the symbol

      [ x ]
           1

   indicates a coordinate system rotation of `x' radians about the
   first, or x-, axis; the corresponding matrix is

      .-                    -.
      |  1      0       0    |
      |                      |
      |  0    cos(x)  sin(x) |
      |                      |
      |  0   -sin(x)  cos(x) |
      `-                    -'

   Remember, this is a COORDINATE SYSTEM rotation by `x' radians; this
   matrix, when applied to a vector, rotates the vector by -x
   radians, not `x' radians. Applying the matrix to a vector yields
   the vector's representation relative to the rotated coordinate
   system.

   The analogous rotation about the second, or y-, axis is
   represented by

      [ x ]
           2

   which symbolizes the matrix

      .-                    -.
      | cos(x)   0   -sin(x) |
      |                      |
      |  0       1      0    |
      |                      |
      | sin(x)   0    cos(x) |
      `-                    -'

   and the analogous rotation about the third, or z-, axis is
   represented by

      [ x ]
           3

   which symbolizes the matrix

      .-                    -.
      |  cos(x)  sin(x)   0  |
      |                      |
      | -sin(x)  cos(x)   0  |
      |                      |
      |  0        0       1  |
      `-                    -'


   The input matrix is assumed to be the product of three
   rotation matrices, each one of the form

      .-                    -.
      |  1      0       0    |
      |                      |
      |  0    cos(r)  sin(r) |     (rotation of `r' radians about the
      |                      |      x-axis),
      |  0   -sin(r)  cos(r) |
      `-                    -'


      .-                    -.
      | cos(s)   0   -sin(s) |
      |                      |
      |  0       1      0    |     (rotation of `s' radians about the
      |                      |      y-axis),
      | sin(s)   0    cos(s) |
      `-                    -'

   or

      .-                    -.
      |  cos(t)  sin(t)   0  |
      |                      |
      | -sin(t)  cos(t)   0  |     (rotation of `t' radians about the
      |                      |      z-axis),
      |  0        0       1  |
      `-                    -'

   where the second rotation axis is not equal to the first or
   third. Any rotation matrix can be factored as a sequence of
   three such rotations, provided that this last criterion is met.

   This routine is related to the Icy routine cspice_eul2m, which
   produces a rotation matrix, given a sequence of Euler angles.
   This routine is a "right inverse" of cspice_eul2m: the sequence of
   calls

      cspice_m2eul, r, axis3, axis2, axis1, angle3, angle2, angle1
      cspice_eul2m, angle3, angle2, angle1, axis3, axis2, axis1, r

   preserves `r' to round-off error.

   On the other hand, the sequence of calls

      cspice_eul2m, angle3, angle2, angle1, axis3, axis2, axis1, r
      cspice_m2eul, r, axis3, axis2, axis1, angle3, angle2, angle1

   preserves `angle3', `angle2', and `angle1' only if the initial
   values of the angle existed within the range of cspice_m2eul's
   output.

Exceptions


   1)  If any of `axis3', `axis2', or `axis1' do not have values in

          { 1, 2, 3 }

       the error SPICE(BADAXISNUMBERS) is signaled by a routine in
       the call tree of this routine.

   2)  If `axis2' is equal to `axis3' or `axis1', the error
       SPICE(BADAXISNUMBERS) is signaled by a routine in the call
       tree of this routine. An arbitrary rotation matrix cannot be
       expressed using a sequence of Euler angles unless the second
       rotation axis differs from the other two.

   3)  If the input matrix `r' is not a rotation matrix, the error
       SPICE(NOTAROTATION) is signaled by a routine in the call tree
       of this routine.

   4)  If `angle3' and `angle1' are not uniquely determined, `angle3'
       is set to zero, and `angle1' is determined.

   5)  If any of the input arguments, `r', `axis3', `axis2' or
       `axis1', is undefined, an error is signaled by the IDL error
       handling system.

   6)  If any of the input arguments, `r', `axis3', `axis2' or
       `axis1', is not of the expected type, or it does not have the
       expected dimensions and size, an error is signaled by the Icy
       interface.

   7)  If any of the output arguments, `angle3', `angle2' or
       `angle1', is not a named variable, an error is signaled by the
       Icy interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ
   ROTATION.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.3, 10-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added
       example's problem statement, and second example.

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections, and
       completed -Particulars section.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.2, 25-JUN-2006 (EDW)

       Added example code and output to -Examples section.
       Expanded -I/O section.

   -Icy Version 1.0.1, 09-DEC-2005 (EDW)

       Added -Examples section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   matrix to euler angles



Fri Dec 31 18:43:06 2021