QTMULT Name
QTMULT
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
Multiply quaternions
Major Topics
Geometry
Calling Sequence
QRESULT = QTMULT(Q1, [/INV1,] Q2, [/INV2])
Description
The function QTMULT performs multiplication of quaternions.
Quaternion multiplication is not component-by-component, but
rather represents the composition of two rotations, namely Q2
followed by Q1.
More than one multiplication can be performed at one time if Q1
and Q2 are 4xN arrays. In that case both input arrays must be of
the same dimension.
If INV1 is set, then the inverse of Q1 is used. This is a
convenience, to avoid the call QTINV(Q1). Of course, INV2 can
be set to use the inverse of Q2.
Note that quaternion multiplication is not commutative.
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
Q1 - array of one or more unit quaternions, the first operand in
the multiplication. For a single quaternion, Q1 should be a
4-vector. For N quaternions, Q1 should be a 4xN array.
If INV1 is set, then the inverse of Q1 is used.
Q2 - same as Q1, for the second operand.
If INV2 is set, then the inverse of Q2 is used.
Returns
The resulting multiplied unit quaternions. For a single inputs,
returns a 4-vector. For N input quaternions, returns N
quaternions as a 4xN array.
Keyword Parameters
INV1 - if set, use QTINV(Q1) in place of Q1.
INV2 - if set, use QTINV(Q2) in place of Q2.
Example
Q1 = qtcompose([0,0,1], 32d*!dpi/180d)
Q2 = qtcompose([1,0,0], 116d*!dpi/180d)
IDL> print, qtmult(q1, q2)
0.81519615 0.23375373 0.14606554 0.50939109
Form a rotation quaternion of 32 degrees around the Z axis, and
116 degrees around the X axis, then multiply the two quaternions.
See Also
QTANG, QTAXIS, QTCOMPOSE, QTERP, QTEXP, QTFIND, QTINV, QTLOG,
QTMAT, QTMULT, QTMULTN, QTPOW, QTVROT
Modification History
Written, July 2001, CM
Documented, Dec 2001, CM
Documentation, allow 1xN or Nx1 multiplies, 27 Jan 2002, CM
Usage message, error checking, 15 Mar 2002, CM
Add the INV1 and INV2 keywords, 30 Aug 2007, CM