cspice_qdq2av

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

#### Abstract

```
CSPICE_QDQ2AV derives angular velocity from a unit quaternion and
its derivative with respect to time.

For important details concerning this module's function, please refer to
the CSPICE routine qdq2av_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.

dq   is a double precision 4-vector representing the derivative
of 'q' with respect to time.

the call:

cspice_qdq2av, q, dq, av

returns:

av   is a double precision 3-vector representing the angular
velocity defined by 'q' and 'dq', that is, the angular
velocity of the frame defined by the rotation matrix
associated with 'q'.

```

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

;;
;; Pick some Euler angles and form a rotation matrix.
;;
angle =  [ -20.d, 50.d, -60.d  ] * cspice_rpd()

cspice_eul2m, angle, angle, angle, 3, 1, 3, m

cspice_m2q, m, q

;;
;; Choose an angular velocity vector.
;;
expav = [ 1.d, 2., 3. ]

;;
;; Form the quaternion derivative.
;;
qav =  [ 0.0, expav ]

cspice_qxq, q, qav, dq

dq = -0.5d * dq

;;
;; Recover angular velocity from 'q' and 'dq' using cspice_qdq2av.
;;
cspice_qdq2av, q, dq, av

;;
;; Now we'll obtain the angular velocity from 'q' and
;; 'dq' by an alternate method.
;;
;; Convert 'q' back to a rotation matrix.
;;
cspice_q2m, q, m

;;
;; Convert 'q' and 'dq' to a rotation derivative matrix.  This
;; somewhat messy procedure is based on differentiating the
;; formula for deriving a rotation from a quaternion, then
;; substituting components of 'q' and 'dq' into the derivative
;; formula.
;;

dm = dblarr(3,3)

dm[0,0]  =  -4.d0  * (   q*dq  +  q*dq  )

dm[1,0]  =   2.d0  * (   q*dq  +  q*dq  \$
- q*dq  -  q*dq  )

dm[2,0]  =   2.d0  * (   q*dq  +  q*dq  \$
+ q*dq  +  q*dq  )

dm[0,1]  =   2.d0  * (   q*dq  +  q*dq  \$
+ q*dq  +  q*dq  )

dm[1,1]  =  -4.d0  * (   q*dq  +  q*dq  )

dm[2,1]  =   2.d0  * (   q*dq  +  q*dq  \$
- q*dq  -  q*dq  )

dm[0,2]  =   2.d0  * (   q*dq  +  q*dq  \$
- q*dq  -  q*dq  )

dm[1,2]  =   2.d0  * (   q*dq  +  q*dq  \$
+ q*dq  +  q*dq )

dm[2,2]  =  -4.d0  * (   q*dq  +  q*dq  )

xtrans = dblarr(6,6)

;;
;; Upper left block:
;;
xtrans[0,0] = m[*,0]
xtrans[0,1] = m[*,1]
xtrans[0,2] = m[*,2]

;;
;; Lower left block:
;;
xtrans[0,3] = dm[*,0]
xtrans[0,4] = dm[*,1]
xtrans[0,5] = dm[*,2]

;;
;; Lower right block:
;;
xtrans[3,3] = m[*,0]
xtrans[3,4] = m[*,1]
xtrans[3,5] = m[*,2]

;;
;; Now use cspice_xf2rav to produce the expected angular velocity.
;;
cspice_xf2rav, xtrans, mout, avx

;;
;; The results should match to nearly full double precision.
;;
print, "Original angular velocity     : ", expav
print, "cspice_qdq2av angular velocity: ", av
print, "cspice_xf2rav angular velocity: ", avx

IDL outputs:

Original angular velocity     :   1.0000000   2.0000000   3.0000000
cspice_qdq2av angular velocity:   1.0000000   2.0000000   3.0000000
cspice_xf2rav angular velocity:   1.0000000   2.0000000   3.0000000

```

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

```

#### Version

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

```

#### Index_Entries

```
angular velocity from  quaternion and derivative

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