cspice_m2eul

 Abstract I/O Examples Particulars Required Reading Version Index_Entries

#### Abstract

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

```

#### I/O

```
Given:

r        the rotation matrix/matrices to factor as a product of three
rotations about specified coordinate axes.  The angles of
these rotations are called "Euler angles".

[3,3]   = size(r); double = class(r)

or

[3,3,n] = size(r); double = class(r)

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

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

The axis numbers must belong to the set {1, 2, 3}.

[1,1] = size(axis3); int32 = class(axis3)
[1,1] = size(axis2); int32 = class(axis2)
[1,1] = size(axis1); int32 = class(axis1)

The values of axisX may be 1, 2, or 3, indicating
the x, y, and z axes respectively. The second axis number
MUST differ from the first and third axis numbers.

the call:

[angle3, angle2, angle1] = cspice_m2eul( r, axis3, axis2, axis1 )

returns:

angle3
angle2
angle1   the Euler angles measured where the angles satisfy

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

If [3,3] = size(r)
then

[1,1] = size(angle3); double = class(angle3)
[1,1] = size(angle2); double = class(angle2)
[1,1] = size(angle1); double = class(angle1)

If [3,3,n] = size(r)
then

[1,n] = size(angle3); double = class(angle3)
[1,n] = size(angle2); double = class(angle2)
[1,n] = size(angle1); double = class(angle1)

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

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 = [ angle3 ]  [ angle2 ]  [ angle1 ]
a           b           a

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

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

r = [ angle3 ]  [ angle2 ]  [ angle1 ],
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.

'angle3', 'angle2', and 'angle1' return with the same
vectorization measure, N, as 'r'.

Note, the call sequence:

[angle3, angle2, angle1] = cspice_m2eul(r, axis3, axis2, axis1)
r = cspice_eul2m(angle3, angle2, angle1, axis3, axis2, axis1)

preserves 'r' to round-off error.

Yet, the call sequence:

r = cspice_eul2m(angle3, angle2, angle1, axis3, axis2, axis1)
[angle3, angle2, angle1] = cspice_m2eul(r, axis3, axis2, axis1)

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

```

#### Examples

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

Example(1):

%
% Scalar example, 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.49127379678135830  0.50872620321864170  0.70699908539882417 ]
[ -0.50872620321864193 -0.49127379678135802  0.70699908539882428]
[  0.70699908539882406 -0.70699908539882439  0.01745240643728360] ];

%
% We want to find angles alpha, delta, kappa such that
%
%
%   ticam  =  [ kappa ]  [ pi/2 - delta ]  [ pi/2 + alpha ] .
%                      3                 1                 3
%
%
% Factor the matrix to the Euler angles corresponding to a
% 3-1-3 rotation.
%
[ kappa, ang2, ang1  ] = cspice_m2eul( ticam, 3, 1, 3 );

alpha  =  ang1          - cspice_halfpi;
delta  =  cspice_halfpi - ang2;

%
%  calculates 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 < 0. )
alpha = alpha + cspice_twopi;
end

if ( kappa < 0. )
kappa = kappa + cspice_twopi;
end

%
% Output the 3-1-3 Euler rotation angles corresponding to 'ticam'.
%
fprintf( '%12.5f   %12.5f   %12.5f\n', ...
[ alpha, delta, kappa ] *cspice_dpr)

MATLAB outputs:

315.00000        1.00000       45.00000

Example(2):

%
% Vectorized example, input an array of ephemeris times, calculate
% the corresponding J2000 to IAU_MOON transformation matrices.
%
cspice_furnsh('standard.tm')

et0 = cspice_str2et( 'Jan 1 2000 12:00:00 TDB' );
et1 = cspice_str2et( 'Jan 1 2010 12:00:00 TDB' );

n     = 10;
times = et0 + (1:n)* (et1 - et0)/n;
quot   = cspice_pxform( 'J2000', 'IAU_MOON', times );

%
% Factor the matrices to the Euler angles corresponding to a
% 3-2-1 rotation set.
%
[a3,a2,a1] = cspice_m2eul( quot, 1,2,3);

%
% Output the 3-2-1 Euler rotation angles corresponding to 'quot'.
%
fprintf( '%12.5f   %12.5f   %12.5f\n', [a1; a2; a3] * cspice_dpr )

cspice_kclear

MATLAB outputs:

-52.93007       18.11962       15.07397
77.30266      -22.59555        3.51974
-150.68645       12.42680      -18.79120
-14.28248        4.91714       21.55874
120.06957      -19.09792      -11.00536
-109.73801       20.66329       -7.52692
23.54335       -8.43440       20.49467
160.13917       -9.11890      -20.58629
-66.71201       21.70068        7.52880

```

#### Particulars

```
None.

```

```
For important details concerning this module's function, please refer to
the CSPICE routine m2eul_c.

MICE.REQ
ROTATION.REQ

```

#### Version

```
-Mice Version 1.0.2, 09-MAR-2015, EDW (JPL)

Edited I/O section to conform to NAIF standard for Mice documentation.

-Mice Version 1.0.1, 30-DEC-2008, EDW (JPL)

Corrected misspellings.

-Mice Version 1.0.0, 22-NOV-2005, EDW (JPL)

```

#### Index_Entries

```
matrix to euler angles

```
`Wed Apr  5 18:00:33 2017`