#include
<MQuaternion.h>
This class provides methods for working with Quaternions. Quaternions can be used to specify orientations and rotations of 3D objects relative to a starting reference, similar to the way that cartesian vectors can be used to specify positions and translations of 3D objects relative to an origin. Quaternions represent orientations as a single rotation, just as rectangular coordinates represent position as a single vector.
Public Member Functions 

MQuaternion ()  
MQuaternion (const MQuaternion &src)  
MQuaternion (double xx, double yy, double zz, double ww)  
MQuaternion (const double q[4])  
MQuaternion (const MVector &a, const MVector &b)  
MQuaternion (const MVector &a, const MVector &b, double angleFactor)  
MQuaternion (double angle, const MVector &axisb)  
~MQuaternion ()  
MQuaternion &  operator= (const MQuaternion &src) 
MQuaternion &  operator= (const MMatrix &matrix) 
MQuaternion &  operator= (const MEulerRotation &matrix) 
MMatrix  asMatrix () const 
MEulerRotation  asEulerRotation () const 
MQuaternion &  setAxisAngle (const MVector &axis, double theta) 
bool  getAxisAngle (MVector &axis, double &theta) const 
MQuaternion &  setToXAxis (double theta) 
MQuaternion &  setToYAxis (double theta) 
MQuaternion &  setToZAxis (double theta) 
MStatus  get (double dest[4]) const 
double  operator[] (unsigned int i) const 
MQuaternion  operator+ (const MQuaternion &other) const 
MQuaternion  operator* (const MQuaternion &other) const 
MQuaternion &  operator*= (const MQuaternion &rhs) 
MQuaternion  operator (const MQuaternion &other) const 
MQuaternion  operator () const 
MQuaternion &  negateIt () 
bool  operator== (const MQuaternion &other) const 
bool  operator!= (const MQuaternion &other) const 
bool  isEquivalent (const MQuaternion &other, double tolerance=1.0e10) const 
MQuaternion &  scaleIt (double scale) 
MQuaternion  normal () const 
MQuaternion &  normalizeIt () 
MQuaternion  conjugate () const 
MQuaternion &  conjugateIt () 
MQuaternion  inverse () const 
MQuaternion &  invertIt () 
MQuaternion  log () const 
MQuaternion  exp () const 
double &  operator[] (unsigned int i) 
NO SCRIPT SUPPORT. 

operator MMatrix () const  
NO SCRIPT SUPPORT. 

Public Attributes 

double  x 
The quaternion's imaginary x
component. 

double  y 
The quaternion's imaginary y
component. 

double  z 
The quaternion's imaginary z
component. 

double  w 
The quaternion's real component. 

Static Public Attributes 

static const MQuaternion  identity 
The multiplicative identity. 

Friends 

OPENMAYA_EXPORT MQuaternion  operator* (double scale, const MQuaternion &other) 
NO SCRIPT SUPPORT. 

OPENMAYA_EXPORT MQuaternion  slerp (const MQuaternion &p, const MQuaternion &q, double t) 
OPENMAYA_EXPORT MQuaternion  slerp (const MQuaternion &p, const MQuaternion &q, double t, short spin) 
NO SCRIPT SUPPORT. 

OPENMAYA_EXPORT MQuaternion  squad (const MQuaternion &p, const MQuaternion &a, const MQuaternion &b, const MQuaternion &q, double t) 
NO SCRIPT SUPPORT. 

OPENMAYA_EXPORT MQuaternion  squad (const MQuaternion &p, const MQuaternion &a, const MQuaternion &b, const MQuaternion &q, double t, short spin) 
NO SCRIPT SUPPORT. 

OPENMAYA_EXPORT MQuaternion  squadPt (const MQuaternion &q0, const MQuaternion &q1, const MQuaternion &q2) 
NO SCRIPT SUPPORT. 

OPENMAYA_EXPORT std::ostream &  operator<< (std::ostream &os, const MQuaternion &q) 
NO SCRIPT SUPPORT. 
MQuaternion::MQuaternion  (  ) 
The default class constructor. Initializes the quaternion to the multiplicative identity.
MQuaternion::MQuaternion  (  const MQuaternion &  src  ) 
The copy constructor. Creates a new quaternion and initializes it to the same values as the given quaternion.
[in]  src  the quaternion object to copy 
MQuaternion::MQuaternion  (  double  xx,  
double  yy,  
double  zz,  
double  ww  
) 
Class constructor. Initializes the quaternion with the explicit x, y, z, and w values provided as arguments.
[in]  xx  the x component of the quaternion 
[in]  yy  the y component of the quaternion 
[in]  zz  the z component of the quaternion. 
[in]  ww  the w component of the quaternion. 
MQuaternion::MQuaternion  (  const double  q[4]  ) 
Class constructor. Initializes the quaternion with the explicit x, y, z, and w values provided in the given double array.
[in]  q  the 4 element array containing the initial x, y, z, and w values 
Class constructor. Creates a new quaternion that will rotate vector a into vector b about their mutually perpendicular axis.
[in]  a  vector to rotate from 
[in]  b  vector to rotate to 
Class constructor. Creates a new quaternion that will rotate vector a into vector b about their mutually perpendicular axis by a given factor.
[in]  a  vector to rotate from 
[in]  b  vector to rotate to 
[in]  angleFactor  the factor by which the rotation should be multiplied; a factor of 1.0 is equivalent to a rotation of vector a into vector b 
MQuaternion::MQuaternion  (  double  angle,  
const MVector &  axis  
) 
This constructor creates a new quaternion whose rotation is expressed by a pivot axis and a rotation (in radians) about that axis. If the length of the axis is too small the quaternion returned will be the identity quaternion.
[in]  angle  the amount of rotation around the axis 
[in]  axis  the axis about which the rotation occurs 
MQuaternion::~MQuaternion  (  ) 
Class destructor.
MQuaternion & MQuaternion::operator=  (  const MQuaternion &  src  ) 
The assignment operator.
[in]  src  the source quaternion 
MQuaternion & MQuaternion::operator=  (  const MMatrix &  matrix  ) 
Convert the given 4X4 homogeneous rotation matrix to a quaternion of unit length.
This methods always returns a quaternion of unit length if it is given a proper orthogonal matrix. A proper othogonal matrix is one such that the determinant of the matrix is one. (If the determinant were 1, this would imply that the orthogonal matrix is also producing a reflection, in addition to a rotation.)
[in]  matrix  the matrix to be converted to a quaternion 
MQuaternion & MQuaternion::operator=  (  const MEulerRotation &  euler  ) 
Convert the given euler rotation to a quaternion.
[in]  euler  the euler rotation to be converted to a quaternion 
MMatrix MQuaternion::asMatrix  (  )  const 
Converts a quaternion to a 4X4 homogeneous rotation matrix. The construction of the matrix assumes that the vectors are going to be multiplied on the left side of the matrix. If the quaternion's length has degenerated, this method will still produce a well behaved matrix.
ReturnValue
MEulerRotation MQuaternion::asEulerRotation  (  )  const 
Converts a quaternion to an euler rotation.
ReturnValue
MQuaternion & MQuaternion::setAxisAngle  (  const MVector &  axis,  
double  theta  
) 
Sets this quaternion to be the rotation as expressed by a pivot axis and a rotation theta (in radians) about that axis. If the axis is too small the quaternion returned will be the identity quaternion.
[in]  axis  the axis about which to rotate 
[in]  theta  the angle of rotation about the axis in radians 
bool MQuaternion::getAxisAngle  (  MVector &  axis,  
double &  theta  
)  const 
Converts this quaternion into a user understandable representation. That is, the quaternion is represented as a pivot vector 'axis' and a rotation 'theta' (in radians) about that pivot vector.
If the identity unit quaternion is attempted to be converted to the pivot axis and angle representation it will be set to a zero degree rotation about the axis that was passed in. (Note that any axis will do, since an infinity of axis with rotation of zero satisfy the identity rotation.) If the axis is zero length, then an arbitrary axis will be chosen (zaxis).
[out]  axis  the axis about which the rotation occurs 
[out]  theta  the angle of rotation about the axis in radians 
MQuaternion & MQuaternion::setToXAxis  (  double  theta  ) 
Sets this quaternion to be the rotation about the X axis of theta (in radians). If the length of the axis is too small the quaternion returned will be the identity quaternion.
[in]  theta  the angle of rotation about the X axis in radians 
MQuaternion & MQuaternion::setToYAxis  (  double  theta  ) 
Sets this quaternion to be the rotation about the Y axis of theta (in radians). If the length of the axis is too small the quaternion returned will be the identity quaternion.
[in]  theta  the angle of rotation about the Y axis in radians 
MQuaternion & MQuaternion::setToZAxis  (  double  theta  ) 
Sets this quaternion to be the rotation about the Z axis of theta (in radians). If the length of the axis is too small the quaternion returned will be the identity quaternion.
[in]  theta  the angle of rotation about the Z axis in radians 
MStatus MQuaternion::get  (  double  dest[4]  )  const 
Extracts the x, y, z, and w components of the quaternion and places them in elements 0, 1, 2, and 3 of the double array passed.
[out]  dest  the array of 4 doubles into which the results are placed. 
double MQuaternion::operator[]  (  unsigned int  i  )  const 
The index operator. If its argument is 0 it will return the x component of the quaternion. If its argument is 1 it will return the y component of the quaternion. If its argument is 2 it will return the z component of the quaternion. If its argument is 3 it will return the w component of the quaternion.
[in]  i  value indicating which component to return 
MQuaternion MQuaternion::operator+  (  const MQuaternion &  other  )  const 
The quaternion addition operator.
[in]  other  the quaternion to be added to this quaternion 
MQuaternion MQuaternion::operator*  (  const MQuaternion &  other  )  const 
This quaternion multiplication operator.
Quaternions in Maya multiply on the right (postmultiply) the same as matrices. Many popular quaternion papers (Shoemake) use premultiplication where quaternions premultiply on the left so you must be aware of this when using quaternions.
In general, if p and q are quaternions, pq != qp, i.e., multiplication does not commute!
[in]  other  the quaternion to be multiplied with this quaternion 
MQuaternion & MQuaternion::operator*=  (  const MQuaternion &  other  ) 
The in place quaternion multiplication operator.
Quaternions in Maya multiply on the right (postmultiply) the same as matrices.
[in]  other  the quaternion to be multiplied with this quaternion 
MQuaternion MQuaternion::operator  (  const MQuaternion &  other  )  const 
The quaternion subtraction operator.
[in]  other  the quaternion to be subtracted from this quaternion 
MQuaternion MQuaternion::operator  (  )  const 
The unary minus operator. Negates the value of each of the x, y, z, and w components of the quaternion.
MQuaternion & MQuaternion::negateIt  (  ) 
Performs an in place negation of the quaternion. The result is a quaternion whose x, y, z, and w values have been negated.
bool MQuaternion::operator==  (  const MQuaternion &  other  )  const 
The quaternion equality operator. This returns true if all four of the x, y, z, and w components are identical.
[in]  other  the quaternion to be compared with this quaternion 
bool MQuaternion::operator!=  (  const MQuaternion &  other  )  const 
The quaternion inequality operator. This returns false if all four of the x, y, z, and w components are identical.
[in]  other  the quaternion to be compared with this quaternion 
bool MQuaternion::isEquivalent  (  const MQuaternion &  other,  
double  tolerance =
1.0e10 

)  const 
This method returns true if this quaternion is equal, within some given tolerance, to the other quaternion.
'tolerance' defaults to kQuaternionEpsilon which is 1.0e10
[in]  other  the quaternion to be compared with this quaternion 
[in]  tolerance  the amount of variation allowed for equivalency 
MQuaternion & MQuaternion::scaleIt  (  double  scale  ) 
Performs an in place scaling of the quaternion. The result is a quaternion whose x, y, z, and w values have been scaled by the specified amount.
[in]  scale  the amount by which the quaternion should be scaled 
MQuaternion MQuaternion::normal  (  )  const 
Returns the normal of this quaternion. The result is a quaternion of unit length.
If the quaternion is zero or has a very small length it will instead be set to the multiplicative identity.
MQuaternion & MQuaternion::normalizeIt  (  ) 
Performs an in place normalization of this quaternion. The result is a quaternion of unit length.
If the quaternion is zero or has a very small length it will instead be set to the multiplicative identity.
MQuaternion MQuaternion::conjugate  (  )  const 
Returns the conjugate of this quaternion. The result is a quaternion whose x, y, and z values have been negated.
MQuaternion & MQuaternion::conjugateIt  (  ) 
Performs an in place conjugation of this quaternion. The result is a quaternion whose x, y, and z values have been negated.
MQuaternion MQuaternion::inverse  (  )  const 
Returns the inverse of this quaternion.
MQuaternion & MQuaternion::invertIt  (  ) 
Performs an in place inversion of this quaternion.
MQuaternion MQuaternion::log  (  )  const 
Returns the natural log of a quaternion. The precondition for using this method is that the quaternion must be normalized.
Note that the log of a unit quaternion is not necessarily a unit quaternion.
MQuaternion MQuaternion::exp  (  )  const 
Exponentiates a quaternion that has a scalar part of zero. The precondition for using this method is that w is zero.
double & MQuaternion::operator[]  (  unsigned int  i  ) 
NO SCRIPT SUPPORT.
The index operator. If its argument is 0 it will return the x component of the quaternion. If its argument is 1 it will return the y component of the quaternion. If its argument is 2 it will return the z component of the quaternion. If its argument is 3 it will return the w component of the quaternion.
[in]  i  value indicating which component to return 
MQuaternion::operator MMatrix  (  )  const 
NO SCRIPT SUPPORT.
Casts a quaternion to a matrix.
OPENMAYA_EXPORT MQuaternion operator*  (  double  scale,  
const MQuaternion &  other  
)  [friend] 
NO SCRIPT SUPPORT.
The multiplication operator that allows the scale to preceed the quaternion.
[in]  scale  the amount by which the quaternion should be scaled 
[in]  other  the quaternion to which the scale should be applied 
OPENMAYA_EXPORT MQuaternion slerp  (  const MQuaternion &  p,  
const MQuaternion &  q,  
double  t  
)  [friend] 
Spherical linear interpolation (abbreviated as slerp) of unit quaternions. As t goes from 0 to 1, the quaternion returned goes from p to q. The interpolation always takes shortest path (in quaternion space) from p to q.
[in]  p  quaternion to rotate from 
[in]  q  quaternion to rotate to 
[in]  t  interpolation value 
OPENMAYA_EXPORT MQuaternion slerp  (  const MQuaternion &  p,  
const MQuaternion &  q,  
double  t,  
short  spin  
)  [friend] 
NO SCRIPT SUPPORT.
Spherical linear interpolation (abbreviated as slerp) of unit quaternions. As t goes from 0 to 1, the quaternion returned goes from p to q. The spin parameter determines how many complete revolutions around the axis will occur as p goes to q. Negative spins will take the "long way" around the great sphere when rotating. (1 can be used to interpolate using the "long" path on the quaternion sphere without any extra spins.)
[in]  p  quaternion to rotate from 
[in]  q  quaternion to rotate to 
[in]  t  interpolation value 
[in]  spin  the number of complete revolutions around the axis 
OPENMAYA_EXPORT MQuaternion squad  (  const MQuaternion &  p,  
const MQuaternion &  a,  
const MQuaternion &  b,  
const MQuaternion &  q,  
double  t  
)  [friend] 
NO SCRIPT SUPPORT.
Compute a point on a cubic curve segment that interpolates p and q and is C1 continuous. Need to use squadPoint or some other suitable method for finding a and b
[in]  p  quaternion to rotate from 
[in]  a  intermediate squad point 
[in]  b  intermediate squad point 
[in]  q  quaternion to rotate to 
[in]  t  interpolation value 
OPENMAYA_EXPORT MQuaternion squad  (  const MQuaternion &  p,  
const MQuaternion &  a,  
const MQuaternion &  b,  
const MQuaternion &  q,  
double  t,  
short  spin  
)  [friend] 
NO SCRIPT SUPPORT.
Compute a point on a cubic curve segment that interpolates p and q and is C1 continuous. Need to use squadPoint or some other suitable method for finding a and b
[in]  p  quaternion to rotate from 
[in]  a  intermediate squad point 
[in]  b  intermediate squad point 
[in]  q  quaternion to rotate to 
[in]  t  interpolation value 
OPENMAYA_EXPORT MQuaternion squadPt  (  const MQuaternion &  q0,  
const MQuaternion &  q1,  
const MQuaternion &  q2  
)  [friend] 
NO SCRIPT SUPPORT.
Generate an intermediate squad point used to produce a C1 continuous spline (using squad). This method uses the average of the tangents of arcs to adjacent points. Therefore, to squad from p to q we need to find a and b in the following manner:
Given: unit quaternion control points we wish to interpolate (q0, q1,..., p1, p, q, q+1,..., qN)
Want: a, b such that squad(p, a, b, q, t) generates a C1 continuous cubic curve from p to q as we vary t from 0 to 1.
Calculation: a = squadPoint(p1, p, q); b = squadPoint(p, q, q+1);
Notes: We only need to compute one squadPoint for each segment (except at endpoints) since the next 'a' value is simply our current 'b' value (ie. a(i) = b(i1) or b(i) = a(i+1)).
[in]  q0  quaternion from which the squad is computed 
[in]  q1  quaternion from which the squad is computed 
[in]  q2  quaternion from which the squad is computed 
OPENMAYA_EXPORT std::ostream& operator<<  (  std::ostream &  os,  
const MQuaternion &  q  
)  [friend] 
NO SCRIPT SUPPORT.
Print the contents of the given quaternion on the given ostream. The format used is [x: x, y: y, z: z, w: w].
[in]  os  the ostream to print to 
[in]  q  the quaternion to be printed 
Autodesk® Maya® 2011 © 19972010 Autodesk, Inc. All rights reserved.  Generated with 1.5.6 