cspice_q2m

 Abstract I/O Examples Particulars Required Reading Version Index_Entries
```
```

#### Abstract

```
CSPICE_Q2M calculates the 3x3 double precision, rotation matrix
corresponding to a specified unit quaternion.

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

```

#### I/O

```
Given:

q   is a unit length double precision 4-vector representing
a SPICE-style quaternion.

Note that multiple styles of quaternions are in use.
This routine will not work properly if the input
quaternions do not conform to the SPICE convention.
See the Particulars section for details.

the call:

cspice_q2m, q, r

returns:

r   a 3x3 double precision rotation matrix representation of
the quaternion.

```

#### 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.

;;
;; Define a unit quaternion.
;;
q = [ sqrt(2.d)/2.d, 0.d, 0.d, -sqrt(2.d)/2.d]
print, q

IDL outputs:   0.70710678    0.0000000    0.0000000  -0.70710678

;;
;; Confirm q satisfies || q || = 1. Calculate q * q.
;;
print, transpose(q) # q

IDL outputs:  1.0000000

;;
;; Convert the quaternion to a matrix form.
;;
cspice_q2m, q, m
print, m

IDL outputs:

0.0000000       1.0000000       0.0000000
-1.0000000       0.0000000       0.0000000
0.0000000       0.0000000       1.0000000

Please note, the call sequence:

cspice_m2q, r, q
cspice_q2m, q,r

preserves 'r' except for round-off error. Yet, the call sequence:

cspice_q2m, q,r
cspice_m2q, r, q

may preserve 'q' or return '-q'.

```

#### Particulars

```
About SPICE quaternions
=======================

There are (at least) two popular "styles" of quaternions; these
differ in the layout of the quaternion elements, the definition
of the multiplication operation, and the mapping between the set
of unit quaternions and corresponding rotation matrices.

SPICE-style quaternions have the scalar part in the first
component and the vector part in the subsequent components. The
SPICE convention, along with the multiplication rules for SPICE
quaternions, are those used by William Rowan Hamilton, the
inventor of quaternions.

Another common quaternion style places the scalar component
last.  This style is often used in engineering applications.

```

```
ICY.REQ
ROTATION.REQ

```

#### Version

```
-Icy Version 1.0.1, 06-NOV-2005, EDW (JPL)

Updated Particulars section to include the
"About SPICE Quaternions" description. Recast
the I/O section to meet Icy format standards.

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

```

#### Index_Entries

```
quaternion to matrix

```
`Wed Apr  5 17:58:03 2017`