C++ API Reference
|
Transformation matrix. More...
#include <MTransformationMatrix.h>
Public Types | |
enum | RotationOrder { kInvalid, kXYZ, kYZX, kZXY, kXZY, kYXZ, kZYX, kLast } |
Order of rotation. More... | |
Public Member Functions | |
~MTransformationMatrix () | |
Class Destructor. | |
MTransformationMatrix () | |
Class Constructor. | |
MTransformationMatrix (const MTransformationMatrix &src) | |
Class Copy Constructor. More... | |
MTransformationMatrix (const MMatrix &src) | |
Class Constructor. More... | |
MTransformationMatrix & | operator= (const MTransformationMatrix &src) |
Copy operator. More... | |
MTransformationMatrix & | operator= (const MMatrix &src) |
Copy operator. More... | |
MMatrix | asMatrix () const |
Returns the four by four matrix that describes this transformation. More... | |
MMatrix | asMatrix (double percent) const |
Returns a matrix that represents the specified percentage of this transformation matrix. More... | |
MMatrix | asMatrixInverse () const |
Returns the inverse of the four by four matrix that describes this transformation. More... | |
MMatrix | asScaleMatrix () const |
Returns scale space matrix. More... | |
MMatrix | asRotateMatrix () const |
Returns rotate space matrix. More... | |
MStatus | getScale (double scale[3], MSpace::Space space) const |
Get the scale component of the transformation matrix. More... | |
MStatus | setScale (const double scale[3], MSpace::Space space) |
Set the scale component of the transformation matrix. More... | |
MStatus | addScale (const double scale[3], MSpace::Space space) |
Add to the scale component by scaling relative to the existing transformation. More... | |
MQuaternion | rotation () const |
Returns the rotation component of the transformation matrix as a quaternion. More... | |
MTransformationMatrix & | rotateTo (const MQuaternion &q) |
Sets the rotation component of the transformation matrix using a quaternion. More... | |
MTransformationMatrix & | rotateBy (const MQuaternion &q, MSpace::Space space, MStatus *ReturnStatus=NULL) |
Adds to the rotation component of the rotation matrix by rotating relative to the existing transformation using a quaternion. More... | |
MEulerRotation | eulerRotation () const |
Returns the rotation component of the transformation matrix as an euler rotation. More... | |
MTransformationMatrix & | rotateTo (const MEulerRotation &e) |
Sets the rotation component of the transformation matrix using an euler rotation. More... | |
MTransformationMatrix & | rotateBy (const MEulerRotation &e, MSpace::Space space, MStatus *ReturnStatus=NULL) |
Adds to the rotation component of the rotation matrix by rotating relative to the existing transformation using an euler rotation. More... | |
MStatus | getRotationQuaternion (double &x, double &y, double &z, double &w) const |
Get the rotation component of the transformation matrix as a quaternion. More... | |
MStatus | setRotationQuaternion (double x, double y, double z, double w) |
Set the rotation component of the transformation matrix using a quaternion. More... | |
MStatus | addRotationQuaternion (double x, double y, double z, double w, MSpace::Space) |
Add to the rotation component by rotating relative to the existing transformation. More... | |
MStatus | getRotation (double[3], RotationOrder &order) const |
Get the rotation component of the transformation matrix in radians. More... | |
MStatus | setRotation (const double rotation[3], RotationOrder order) |
Set the rotation component of the transformation matrix. More... | |
MStatus | addRotation (const double rotation[3], RotationOrder order, MSpace::Space) |
Add to the rotation component by rotating relative to the existing transformation. More... | |
RotationOrder | rotationOrder (MStatus *ReturnStatus=NULL) const |
Returns the rotation order for the transform matrix. More... | |
MStatus | reorderRotation (const RotationOrder &order) |
Reorders the x, y, and z components of the rotation of this transform. More... | |
MStatus | setToRotationAxis (const MVector &axis, double rotation) |
Sets the rotation given an axis and a rotation about it. More... | |
MQuaternion | rotationOrientation () const |
Returns the rotation orientation for the transformation matrix. More... | |
MTransformationMatrix & | setRotationOrientation (const MQuaternion &q) |
Sets the rotation orientation for the transformation matrix. More... | |
MVector | getTranslation (MSpace::Space, MStatus *ReturnStatus=NULL) const |
Returns the translation component of the translation as a vector in centimeters. More... | |
MStatus | setTranslation (const MVector &vector, MSpace::Space) |
Set the translation component of the transformation matrix in centimeters. More... | |
MStatus | addTranslation (const MVector &vector, MSpace::Space) |
Add to the translation component by translating relative to the existing transformation. More... | |
MStatus | setShear (const double shear[3], MSpace::Space space) |
Set the shear component of the transformation matrix. More... | |
MStatus | getShear (double shear[3], MSpace::Space space) const |
Get the shear component of the transformation matrix. More... | |
MStatus | addShear (const double shear[3], MSpace::Space space) |
Add to the shear component by shearing relative to the existing transformation. More... | |
MPoint | scalePivot (MSpace::Space, MStatus *ReturnStatus=NULL) const |
Returns the pivot around which the scale is applied. More... | |
MStatus | setScalePivot (const MPoint &, MSpace::Space, bool balance) |
Set the pivot around which the scale is applied. More... | |
MVector | scalePivotTranslation (MSpace::Space, MStatus *ReturnStatus=NULL) const |
Returns the scale pivot translation. More... | |
MStatus | setScalePivotTranslation (const MVector &vector, MSpace::Space) |
Set the pivot translation. More... | |
MPoint | rotatePivot (MSpace::Space, MStatus *ReturnStatus=NULL) const |
Returns the pivot around which the rotation is applied. More... | |
MStatus | setRotatePivot (const MPoint &point, MSpace::Space, bool balance) |
Set the pivot around which the rotation is applied. More... | |
MVector | rotatePivotTranslation (MSpace::Space space, MStatus *ReturnStatus=NULL) const |
Returns the rotation pivot translation. More... | |
MStatus | setRotatePivotTranslation (const MVector &vector, MSpace::Space space) |
Set the pivot translation. More... | |
bool | isEquivalent (const MTransformationMatrix &other, double tolerance=MTransformationMatrix_kTol) const |
Returns true if this transform matrix is equivalent to the one passed in within a certain tolerance. More... | |
bool | operator== (const MTransformationMatrix &other) const |
Equality operator. More... | |
bool | operator!= (const MTransformationMatrix &other) const |
Inequality operator. More... | |
MStatus | getRotation (double[3], RotationOrder &order, MSpace::Space) const |
Deprecated in 2019.0 More... | |
MStatus | setRotation (const double rotation[3], RotationOrder order, MSpace::Space) |
Deprecated in 2019.0 More... | |
MStatus | getRotationQuaternion (double &x, double &y, double &z, double &w, MSpace::Space) const |
Deprecated in 2019.0 More... | |
MStatus | setRotationQuaternion (double x, double y, double z, double w, MSpace::Space) |
Deprecated in 2019.0 More... | |
MVector | translation (MSpace::Space, MStatus *ReturnStatus=NULL) const |
Deprecated in 2019.0 More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
Static Public Attributes | |
static const MTransformationMatrix | identity |
The identity transformation matrix. | |
Transformation matrix.
An MTransformationMatrix allows the manipulation of the individual transformation components (eg scale, rotation, shear, etc) of a four by four transformation matrix.
The transformation in the node is represented as a 4x4 transformation matrix. This class allows access to the whole matrix, or the individual components (eg scale, rotation, shear, etc) of the transformation. This breakdown provides animators fine control over the animation of these parameters. Therefore, it is necessary to describe the order in which these attributes are applied to build the final matrix attribute.
A transformation matrix is composed of the following components:
Note that the default RotationOrder is kXYZ.
The matrices are post-multiplied in Maya. For example, to transform a point P from object-space to world-space (P') you would need to post-multiply by the worldMatrix. (P' = P x WM)
The transformation matrix is then constructed as follows:
where 'x' denotes matrix multiplication and '-1' denotes matrix inversion
enum RotationOrder |
Order of rotation.
Enumerator | |
---|---|
kInvalid |
|
kXYZ |
|
kYZX |
|
kZXY |
|
kXZY |
|
kYXZ |
|
kZYX |
|
kLast |
|
MTransformationMatrix | ( | const MTransformationMatrix & | src | ) |
Class Copy Constructor.
[in] | src | transform matrix to be copied |
MTransformationMatrix | ( | const MMatrix & | src | ) |
Class Constructor.
[in] | src | matrix to be copied |
MTransformationMatrix & operator= | ( | const MTransformationMatrix & | src | ) |
Copy operator.
[in] | src | transform matrix to be copied |
MTransformationMatrix & operator= | ( | const MMatrix & | src | ) |
Copy operator.
[in] | src | matrix to be copied |
MMatrix asMatrix | ( | ) | const |
Returns the four by four matrix that describes this transformation.
MMatrix asMatrix | ( | double | percent | ) | const |
Returns a matrix that represents the specified percentage of this transformation matrix.
[in] | percent | percent of the transformation to return |
MMatrix asMatrixInverse | ( | ) | const |
Returns the inverse of the four by four matrix that describes this transformation.
MMatrix asScaleMatrix | ( | ) | const |
Returns scale space matrix.
The scale space matrix takes points from object space to the space immediately following scale and shear transformations.
MMatrix asRotateMatrix | ( | ) | const |
Returns rotate space matrix.
The rotate space matrix takes points from object space to the space immediately following the scale/shear/rotation transformations.
MStatus getScale | ( | double | scale[3], |
MSpace::Space | space | ||
) | const |
Get the scale component of the transformation matrix.
[out] | scale | storage for the scale component |
[in] | space | transform space in which to get the scale |
MStatus setScale | ( | const double | scale[3], |
MSpace::Space | space | ||
) |
Set the scale component of the transformation matrix.
[in] | scale | new scale component |
[in] | space | transform space in which to perform the scale |
MStatus addScale | ( | const double | scale[3], |
MSpace::Space | space | ||
) |
Add to the scale component by scaling relative to the existing transformation.
[in] | scale | relative value to scale by |
[in] | space | transform space in which to perform the scale |
MQuaternion rotation | ( | ) | const |
Returns the rotation component of the transformation matrix as a quaternion.
The rotation is returned in MSpace::kTransform space.
MTransformationMatrix & rotateTo | ( | const MQuaternion & | q | ) |
Sets the rotation component of the transformation matrix using a quaternion.
The rotation is performed in MSpace::kTransform space.
[in] | q | the quaternion to which the rotation component of the transformation matrix should be set |
MTransformationMatrix & rotateBy | ( | const MQuaternion & | q, |
MSpace::Space | space, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Adds to the rotation component of the rotation matrix by rotating relative to the existing transformation using a quaternion.
The only valid transformation spaces for this method are MSpace::kTransform and MSpace::kPreTransform/MSpace::kObject. All other spaces are treated as being equivalent to MSpace::kTransform.
[in] | q | the quaternion that indicates how much the transformation matrix will be rotated by |
[in] | space | the space in which the rotation is performed |
[out] | ReturnStatus | return status |
MEulerRotation eulerRotation | ( | ) | const |
Returns the rotation component of the transformation matrix as an euler rotation.
MTransformationMatrix & rotateTo | ( | const MEulerRotation & | e | ) |
Sets the rotation component of the transformation matrix using an euler rotation.
The rotation is performed in MSpace::kTransform space.
[in] | e | the euler rotation to which the rotation component of the transformation matrix should be set |
MTransformationMatrix & rotateBy | ( | const MEulerRotation & | e, |
MSpace::Space | space, | ||
MStatus * | ReturnStatus = NULL |
||
) |
Adds to the rotation component of the rotation matrix by rotating relative to the existing transformation using an euler rotation.
The only valid transformation spaces for this method are MSpace::kTransform and MSpace::kPreTransform/MSpace::kObject. All other spaces are treated as being equivalent to MSpace::kTransform.
[in] | e | the euler rotation that indicates how much the transformation matrix will be rotated by |
[in] | space | the space in which the rotation is performed |
[out] | ReturnStatus | return status |
MStatus getRotationQuaternion | ( | double & | x, |
double & | y, | ||
double & | z, | ||
double & | w | ||
) | const |
Get the rotation component of the transformation matrix as a quaternion.
The rotation is retrieved in MSpace::kTransform space.
[out] | x | storage for the x component of the quaternion |
[out] | y | storage for the y component of the quaternion |
[out] | z | storage for the z component of the quaternion |
[out] | w | storage for the w component of the quaternion |
MStatus setRotationQuaternion | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) |
Set the rotation component of the transformation matrix using a quaternion.
The rotation is set in MSpace::kTransform space.
[in] | x | x component of new quaternion |
[in] | y | y component of new quaternion |
[in] | z | z component of new quaternion |
[in] | w | w component of new quaternion |
MStatus addRotationQuaternion | ( | double | x, |
double | y, | ||
double | z, | ||
double | w, | ||
MSpace::Space | space | ||
) |
Add to the rotation component by rotating relative to the existing transformation.
Rotation is a quaternion. The only valid transformation spaces for this method are MSpace::kTransform and MSpace::kPreTransform. All other spaces are treated as being equivalent to MSpace::kTransform.
[in] | x | x component of quaternion |
[in] | y | y component of quaternion |
[in] | z | z component of quaternion |
[in] | w | w component of quaternion |
[in] | space | transformation space in which to perform the operation |
MStatus getRotation | ( | double | rot[3], |
RotationOrder & | order | ||
) | const |
Get the rotation component of the transformation matrix in radians.
The rotation is retrieved in MSpace::kTransform space.
[out] | rot | storage for the rotation in radians |
[out] | order | storage for the rotation order |
MStatus setRotation | ( | const double | rot[3], |
RotationOrder | order | ||
) |
Set the rotation component of the transformation matrix.
The rotation is set in MSpace::kTransform space.
[in] | rot | new rotation component in radians |
[in] | order | order in which to apply rotations |
MStatus addRotation | ( | const double | rot[3], |
RotationOrder | order, | ||
MSpace::Space | space | ||
) |
Add to the rotation component by rotating relative to the existing transformation.
The only valid transformation spaces for this method are MSpace::kTransform and MSpace::kPreTransform. All other spaces are treated as being equivalent to MSpace::kTransform.
[in] | rot | relative value to rotate by |
[in] | order | order in which to apply the rotation components |
[in] | space | transform space in which to perform the rotation |
MTransformationMatrix::RotationOrder rotationOrder | ( | MStatus * | ReturnStatus = NULL | ) | const |
Returns the rotation order for the transform matrix.
That is the order in which the Euler angles are applied to create the end rotation.
[out] | ReturnStatus | return status |
MStatus reorderRotation | ( | const RotationOrder & | order | ) |
Reorders the x, y, and z components of the rotation of this transform.
The overall rotation will remain the same. This operation is not unique, so spin information will be lost.
[in] | order | new order of the rotations |
Sets the rotation given an axis and a rotation about it.
[in] | axis | axis to rotate about |
[in] | rotation | rotation in radians |
MQuaternion rotationOrientation | ( | ) | const |
Returns the rotation orientation for the transformation matrix.
The rotation orientation is the rotation that orients the local rotation space. The rotation is returned in MSpace::kTransform space.
MTransformationMatrix & setRotationOrientation | ( | const MQuaternion & | q | ) |
Sets the rotation orientation for the transformation matrix.
The rotation orientation is the rotation that orients the local rotation space. The rotation is set in MSpace::kTransform space.
[in] | q | Rotation quaternion. |
MVector getTranslation | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns the translation component of the translation as a vector in centimeters.
[in] | space | space in which to perform the translation |
[out] | ReturnStatus | return status |
MStatus setTranslation | ( | const MVector & | vector, |
MSpace::Space | space | ||
) |
Set the translation component of the transformation matrix in centimeters.
[in] | vector | new translation component in centimeters. |
[in] | space | transform space in which to perform the translation |
MStatus addTranslation | ( | const MVector & | vector, |
MSpace::Space | space | ||
) |
Add to the translation component by translating relative to the existing transformation.
[in] | vector | relative value to translate by |
[in] | space | transform space in which to perform the scale |
MStatus setShear | ( | const double | shear[3], |
MSpace::Space | space | ||
) |
Set the shear component of the transformation matrix.
The shear values represent (xy, xz, yx).
[in] | shear | new shear component |
[in] | space | transform space in which to perform the shear |
MStatus getShear | ( | double | shear[3], |
MSpace::Space | space | ||
) | const |
Get the shear component of the transformation matrix.
[out] | shear | Shear. |
[in] | space | Transform space in which to get the shear. |
MStatus addShear | ( | const double | shear[3], |
MSpace::Space | space | ||
) |
Add to the shear component by shearing relative to the existing transformation.
[in] | shear | relative value to shear by |
[in] | space | transform space in which to perform the shear |
MPoint scalePivot | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns the pivot around which the scale is applied.
[in] | space | space in which to get the pivot |
[out] | ReturnStatus | return status |
MStatus setScalePivot | ( | const MPoint & | point, |
MSpace::Space | space, | ||
bool | balance | ||
) |
Set the pivot around which the scale is applied.
If balance if true, then the overall transformation matrix will not change and a compensating transformation will be added to the scale transformation to achieve this.
[in] | point | new scale pivot |
[in] | space | transform space in which to set the scale pivot |
[in] | balance | whether to balance the matrix |
MVector scalePivotTranslation | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns the scale pivot translation.
This is the translation that is used to compensate for the movement of the scale pivot.
[in] | space | space in which to get the pivot |
[out] | ReturnStatus | return status |
MStatus setScalePivotTranslation | ( | const MVector & | vector, |
MSpace::Space | space | ||
) |
Set the pivot translation.
This component is used to preserve existing scale transformations when moving pivot. This method will only be useful to advanced users.
[in] | vector | new scale pivot translation |
[in] | space | transform space in which to set the scale translation |
MPoint rotatePivot | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns the pivot around which the rotation is applied.
[in] | space | space in which to get the pivot |
[out] | ReturnStatus | return status |
MStatus setRotatePivot | ( | const MPoint & | point, |
MSpace::Space | space, | ||
bool | balance | ||
) |
Set the pivot around which the rotation is applied.
If balance if true, then the overall transformation matrix will not change and a compensating transformation will be added to the rotation transformation to achieve this.
[in] | point | new rotation pivot |
[in] | space | transform space in which to set the pivot |
[in] | balance | whether to balance the matrix |
MVector rotatePivotTranslation | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Returns the rotation pivot translation.
This is the translation that is used to compensate for the movement of the rotation pivot.
[in] | space | space in which to get the pivot translation |
[out] | ReturnStatus | return status |
MStatus setRotatePivotTranslation | ( | const MVector & | vector, |
MSpace::Space | space | ||
) |
Set the pivot translation.
This component is used to preserve existing transformations when moving pivot. This method will only be useful to advanced users.
[in] | vector | new rotation pivot translation |
[in] | space | transform space in which to set the rotation translation |
bool isEquivalent | ( | const MTransformationMatrix & | other, |
double | tol = MTransformationMatrix_kTol |
||
) | const |
Returns true if this transform matrix is equivalent to the one passed in within a certain tolerance.
[in] | other | transform matrix to test against |
[in] | tol | tolerance to test using |
bool operator== | ( | const MTransformationMatrix & | other | ) | const |
Equality operator.
[in] | other | transform matrix to test against |
bool operator!= | ( | const MTransformationMatrix & | other | ) | const |
Inequality operator.
[in] | other | transform matrix to test against |
MStatus getRotation | ( | double | rot[3], |
RotationOrder & | order, | ||
MSpace::Space | space | ||
) | const |
Deprecated in 2019.0
This method will be removed in a future Maya release.
The transformation space argument was always treated as MSpace::kTransform regardless of the actual argument.
Get the rotation component in radians of the transformation matrix.
[out] | rot | storage for the rotation in radians |
[out] | order | storage for the rotation order |
[in] | space | transform space in which to get the rotation |
MStatus setRotation | ( | const double | rot[3], |
RotationOrder | order, | ||
MSpace::Space | space | ||
) |
Deprecated in 2019.0
The transformation space argument was always treated as MSpace::kTransform regardless of the actual argument.
Set the rotation component of the transformation matrix.
[in] | rot | new rotation component |
[in] | order | order in which to apply rotations |
[in] | space | transform space in which to perform the rotation |
MStatus getRotationQuaternion | ( | double & | x, |
double & | y, | ||
double & | z, | ||
double & | w, | ||
MSpace::Space | space | ||
) | const |
Deprecated in 2019.0
The transformation space argument was always treated as MSpace::kTransform regardless of the actual argument.
Get the rotation component of the transformation matrix as a quaternion.
[out] | x | storage for the x component of the quaternion |
[out] | y | storage for the y component of the quaternion |
[out] | z | storage for the z component of the quaternion |
[out] | w | storage for the w component of the quaternion |
[in] | space | transform space in which to get the rotation |
MStatus setRotationQuaternion | ( | double | x, |
double | y, | ||
double | z, | ||
double | w, | ||
MSpace::Space | space | ||
) |
Deprecated in 2019.0
The transformation space argument was always treated as MSpace::kTransform regardless of the actual argument.
Set the rotation component of the transformation matrix using a quaternion.
[in] | x | x component of new quaternion |
[in] | y | y component of new quaternion |
[in] | z | z component of new quaternion |
[in] | w | w component of new quaternion |
[in] | space | transform space in which to perform the rotation |
MVector translation | ( | MSpace::Space | space, |
MStatus * | ReturnStatus = NULL |
||
) | const |
Deprecated in 2019.0
Returns the translation component of the translation as a vector in centimeters.
[in] | space | space in which to perform the translation |
[out] | ReturnStatus | return status |
|
static |
Returns the name of this class.