>  Docs Center  >  Libraries  >  Markwardt  >  QTFIND
Libraries

QTFIND

QTFIND

Name


  QTFIND

Author


  Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
  craigm@lheamail.gsfc.nasa.gov
  UPDATED VERSIONs can be found on my WEB PAGE:
      http://cow.physics.wisc.edu/~craigm/idl/idl.html

Purpose


  Find quaternion(s) from direction cosine matrix

Major Topics


  Geometry

Calling Sequence


  Q = QTFIND(MATRIX)

Description



  The function QTFIND determines one or more unit quaternions from
  direction cosine matrices.
  This routine is optimized to avoid singularities which occur when
  any one of the quaternion components is nearly zero. Up to four
  different transformations are attempted to maximize the precision
  of all four quaternion components.
  QTFIND and QTMAT are functional inverses: use QTFIND to convert a
  known direction cosine matrix to a new quaternion; use QTMAT to
  convert a known quaternion to matrix representation.
  Conventions for storing quaternions vary in the literature and from
  library to library. This library uses the convention that the
  first three components of each quaternion are the 3-vector axis of
  rotation, and the 4th component is the rotation angle. Expressed
  in formulae, a single quaternion is given by:
    Q(0:2) = [VX, VY, VZ]*SIN(PHI/2)
    Q(3) = COS(PHI/2)
  where PHI is the rotation angle, and VAXIS = [VX, VY, VZ] is the
  rotation eigen axis expressed as a unit vector. This library
  accepts quaternions of both signs, but by preference returns
  quaternions with a positive 4th component.

Inputs



  MATRIX - array of one or more direction cosine matrices. For a
            single matrix, MATRIX should be a 3x3 array. For N
            matrices, MATRIX should be a 3x3xN array. The arrays are
            assumed to be valid rotation matrices.

Returns



  The resulting unit quaternions. For a single matrix, returns a
  single quaternion as a 4-vector. For N matrices, returns N
  quaternions as a 4xN array.

Keyword Parameters



  NONE

Example



  ;; Form a rotation matrix about the Z axis by 32 degrees
  th1 = 32d*!dpi/180
  mat1 = [[cos(th1),-sin(th1),0],[sin(th1),cos(th1),0],[0,0,1]]
 
  ;; Form a rotation matrix about the X axis by 116 degrees
  th2 = 116d*!dpi/180
  mat2 = [[1,0,0],[0,cos(th2),-sin(th2)],[0,sin(th2),cos(th2)]]
  ;; Find the quaternion that represents MAT1, MAT2 and the
  composition of the two, MAT2 ## MAT1.
    print, qtfind(mat1), qtfind(mat2), qtfind(mat2 ## mat1)
      0.0000000 0.0000000 0.27563736 0.96126170
      0.84804810 0.0000000 0.0000000 0.52991926
      0.81519615 -0.23375373 0.14606554 0.50939109

See Also


  QTANG, QTAXIS, QTCOMPOSE, QTERP, QTEXP, QTFIND, QTINV, QTLOG,
  QTMAT, QTMULT, QTPOW, QTVROT

Modification History


  Written, July 2001, CM
  Documented, Dec 2001, CM
  Re-added check to enforce q(3) GE 0, 15 Mar 2002, CM
  Usage message, error checking, 15 Mar 2002, CM



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us