C++ API Reference

A matrix math class for 4x4 matrices of doubles. More...

#include <MMatrix.h>

Public Member Functions

 MMatrix ()
 The default contstructor. More...
 
 MMatrix (const MMatrix &src)
 The copy Constructor. More...
 
 MMatrix (const double m[4][4])
 Initialize the instance with a 4x4 matrix of doubles. More...
 
 MMatrix (const float m[4][4])
 Initialize the instance with a 4x4 matrix of floats. More...
 
 ~MMatrix ()
 The class destructor.
 
MMatrixoperator= (const MMatrix &)
 The assignment operator. More...
 
double operator() (unsigned int row, unsigned int col) const
 Index operator. More...
 
const double * operator[] (unsigned int row) const
 Index operator. More...
 
MStatus get (double dest[4][4]) const
 Fill a 4x4 matrix of doubles with the elements from the instance. More...
 
MStatus get (float dest[4][4]) const
 Fill a 4x4 matrix of floats with the elements from the instance. More...
 
MMatrix transpose () const
 Compute and return the transpose of this instance. More...
 
MMatrixsetToIdentity ()
 Set this instance to the 4x4 identity matrix. More...
 
MMatrixsetToProduct (const MMatrix &left, const MMatrix &right)
 Set this instance to the inner product of the two argument matrices. More...
 
MMatrixoperator+= (const MMatrix &right)
 The in place matrix addition operator. More...
 
MMatrix operator+ (const MMatrix &right) const
 The matrix addition operator. More...
 
MMatrixoperator-= (const MMatrix &right)
 The in place matrix subtraction operator. More...
 
MMatrix operator- (const MMatrix &right) const
 The matrix subtraction operator. More...
 
MMatrixoperator*= (const MMatrix &right)
 The in place matrix multiplication operator. More...
 
MMatrix operator* (const MMatrix &right) const
 The matrix multiplication operator. More...
 
MMatrixoperator*= (double)
 The in place matrix multiply by a scalar operator. More...
 
MMatrix operator* (double) const
 The matrix multiply by a scalar operator. More...
 
bool operator== (const MMatrix &other) const
 The matrix equality operator. More...
 
bool operator!= (const MMatrix &other) const
 The matrix inequality operator. More...
 
MMatrix inverse () const
 Compute and return the inverse of this instance. More...
 
MMatrix adjoint () const
 Compute and return the adjoint of this instance. More...
 
MMatrix homogenize () const
 Compute and return a homogenized version of this instance. More...
 
double det4x4 () const
 Compute and return the determinant of this instance. More...
 
double det3x3 () const
 Compute and return the determinant of the upper left 3x3 submatrix of this instance. More...
 
bool isEquivalent (const MMatrix &other, double tolerance=MMatrix_kTol) const
 Determine if the given matrix is equivalent to this instance within the specified tolerance. More...
 
bool isSingular () const
 Determines if the given matrix is singular. More...
 
double & operator() (unsigned int row, unsigned int col)
 NO SCRIPT SUPPORT. More...
 
double * operator[] (unsigned int row)
 NO SCRIPT SUPPORT. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Public Attributes

double matrix [4][4]
 The matrix data.
 

Static Public Attributes

static const MMatrix identity
 The identity matrix.
 

Friends

OPENMAYA_EXPORT MMatrix operator* (double, const MMatrix &right)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT std::ostream & operator<< (std::ostream &os, const MMatrix &m)
 NO SCRIPT SUPPORT. More...
 

Detailed Description

A matrix math class for 4x4 matrices of doubles.

This class provides access to Maya's internal matrix math library allowing matrices to be handled easily, and in a manner compatible with internal Maya data structures.

All methods that query the matrix are threadsafe, all methods that modify the matrix are not threadsafe.

Examples:
AbcBullet/AttributesWriter.cpp, AbcBullet/MayaTransformCollectionWriter.cpp, AbcBullet/MayaTransformCollectionWriter.h, AbcExport/AbcWriteJob.cpp, AbcExport/AbcWriteJob.h, AbcExport/AttributesWriter.cpp, AbcExport/MayaNurbsCurveWriter.cpp, AbcImport/XformHelper.cpp, apiMeshShape/apiMeshShape.cpp, apiMeshShape/apiMeshShape.h, apiMeshShape/apiMeshSubSceneOverride.cpp, apiMeshShape/apiMeshSubSceneOverride.h, basicBlendShape/basicBlendShape.cpp, basicBlendShapeDeformer/basicBlendShapeDeformer.cpp, basicMorphNode/basicMorphNode.cpp, basicSkinCluster/basicSkinCluster.cpp, cgFx/cgfxAttrDef.cpp, cgFx/cgfxAttrDef.h, cgFx/cgfxShaderNode.cpp, cgFx/cgfxVector.cpp, closestPointCmd/closestPointCmd.cpp, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.cpp, constraintEvaluator/constraintEvaluator.cpp, cvColorNode/cvColorNode.cpp, dagPoseInfoCmd/dagPoseInfoCmd.cpp, dx11Shader/dx11Shader.cpp, dx11Shader/dx11Shader.h, footPrintNode_SubSceneOverride/footPrintNode_SubSceneOverride.cpp, glslShader/GLSLShader.cpp, gpuCache/CacheReaderAlembic.cpp, gpuCache/CacheReaderAlembic.h, gpuCache/CacheWriter.cpp, gpuCache/CacheWriter.h, gpuCache/CacheWriterAlembic.cpp, gpuCache/gpuCacheCmd.cpp, gpuCache/gpuCacheDrawOverride.cpp, gpuCache/gpuCacheDrawTraversal.h, gpuCache/gpuCacheFrustum.cpp, gpuCache/gpuCacheFrustum.h, gpuCache/gpuCacheGLPickingSelect.cpp, gpuCache/gpuCacheIsectUtil.cpp, gpuCache/gpuCacheRasterSelect.cpp, gpuCache/gpuCacheSample.cpp, gpuCache/gpuCacheSample.h, gpuCache/gpuCacheShapeNode.cpp, gpuCache/gpuCacheSubSceneOverride.cpp, gpuCache/gpuCacheUnitBoundingBox.cpp, gpuCache/gpuCacheUnitBoundingBox.h, gpuCache/gpuCacheVBOProxy.cpp, hlslShader/hlslShader.cpp, hwPhongShader/hwPhongShader.cpp, identityGeomFilter/identityGeomFilter.cpp, identityNode/identityNode.cpp, ik2Bsolver/AwMatrix.h, instancerListCmd/instancerListCmd.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.cpp, lensDistortionCallback/lensDistortionCallback.cpp, manipOverride/rockingTransform2.cpp, manipOverride/rockingTransform2.h, MayaPluginForSpreticle/spReticleLoc.cpp, MayaPluginForSpreticle/spReticleLoc.h, offsetNode/offsetNode.cpp, ownerEmitter/ownerEmitter.cpp, rawfootPrintNode/rawfootPrintNode.cpp, richMoveCmd/richMoveCmd.cpp, rockingTransform/rockingTransform.cpp, rockingTransform/rockingTransform.h, rockingTransformCheck/rockingTransform.cpp, rockingTransformCheck/rockingTransform.h, sampleCmd/sampleCmd.cpp, sampleParticles/sampleParticles.cpp, simpleEmitter/simpleEmitter.cpp, simpleFluidEmitter/simpleFluidEmitter.cpp, simpleFluidEmitter/simpleFluidEmitter.h, surfaceTwistCmd/surfaceTwistCmd.cpp, sweptEmitter/sweptEmitter.cpp, swissArmyManip/swissArmyManip.cpp, torusField/torusField.cpp, viewDX11DeviceAccess/viewDX11DeviceAccess.cpp, viewRenderOverride/viewRenderOverrideOperations.cpp, viewRenderOverride/viewRenderOverrideUserOperation.cpp, viewRenderOverridePointLightShadows/viewRenderOverridePointLightShadows.cpp, viewRenderOverrideShadows/viewRenderOverrideShadows.cpp, and yTwistNode/yTwistNode.cpp.

Constructor & Destructor Documentation

MMatrix ( )

The default contstructor.

The instance is initialized to the 4x4 identity matrix.

MMatrix ( const MMatrix src)

The copy Constructor.

Parameters
[in]srcMatrix to copy data from
MMatrix ( const double  src_matrix[4][4])

Initialize the instance with a 4x4 matrix of doubles.

Parameters
[in]src_matrix4x4 matrix of doubles
MMatrix ( const float  src_matrix[4][4])

Initialize the instance with a 4x4 matrix of floats.

Parameters
[in]src_matrix4x4 matrix of floats

Member Function Documentation

MMatrix & operator= ( const MMatrix src)

The assignment operator.

Parameters
[in]srcMatrix whose value will be assigned to this one.
Returns
This matrix.
double operator() ( unsigned int  row,
unsigned int  col 
) const
inline

Index operator.

Given row and column indices, it will return the value at the specified location in the matrix.

Parameters
[in]rowindex of the row to access
[in]colindex of the column to access
Returns
  • the value at the specified location in the matrix.
const double * operator[] ( unsigned int  row) const
inline

Index operator.

Returns an entire row of the matrix as an array of doubles.

Parameters
[in]rowindex of the row to access
Returns
  • double array containing the values of the specified row
MStatus get ( double  dest[4][4]) const

Fill a 4x4 matrix of doubles with the elements from the instance.

Parameters
[out]dest4x4 matrix of doubles to populate
Returns
MS::kSuccess when success, MS::kFailure otherwise
Examples:
cgFx/cgfxShaderNode.cpp, cgFx/cgfxVector.cpp, dx11Shader/dx11Shader.cpp, glslShader/GLSLShader.cpp, gpuCache/gpuCacheCmd.cpp, and viewRenderOverride/viewRenderOverrideUserOperation.cpp.
MStatus get ( float  dest[4][4]) const

Fill a 4x4 matrix of floats with the elements from the instance.

Parameters
[out]dest4x4 matrix of floats to populate
Returns
MS::kSuccess when success, MS::kFailure otherwise
MMatrix transpose ( ) const

Compute and return the transpose of this instance.

Returns
The transposed matrix
Examples:
cgFx/cgfxShaderNode.cpp, gpuCache/gpuCacheCmd.cpp, and offsetNode/offsetNode.cpp.
MMatrix & setToIdentity ( )

Set this instance to the 4x4 identity matrix.

Returns
This matrix.
Examples:
AbcExport/AbcWriteJob.cpp, cgFx/cgfxShaderNode.cpp, gpuCache/gpuCacheIsectUtil.cpp, and gpuCache/gpuCacheShapeNode.cpp.
MMatrix & setToProduct ( const MMatrix left,
const MMatrix right 
)

Set this instance to the inner product of the two argument matrices.

Parameters
[in]leftthe left hand matrix for the operation
[in]rightthe right hand matrix for the operation
Returns
This matrix.
MMatrix & operator+= ( const MMatrix right)

The in place matrix addition operator.

Modifies this matrix.

Parameters
[in]rightMatrix to add.
Returns
This matrix.
MMatrix operator+ ( const MMatrix right) const

The matrix addition operator.

Does not modify this matrix.

Parameters
[in]rightMatrix to add to this one.
Returns
New matrix containing the result.
MMatrix & operator-= ( const MMatrix right)

The in place matrix subtraction operator.

Modifies this matrix.

Parameters
[in]rightMatrix to add to this one.
Returns
This matrix.
MMatrix operator- ( const MMatrix right) const

The matrix subtraction operator.

Does not modify this matrix.

Parameters
[in]rightMatrix to subtract from this one.
Returns
New matrix containing the result.
MMatrix & operator*= ( const MMatrix right)

The in place matrix multiplication operator.

Modifies this matrix.

Parameters
[in]rightMatrix to multiply this one by.
Returns
This matrix.
MMatrix operator* ( const MMatrix right) const

The matrix multiplication operator.

Does not modify this matrix.

Parameters
[in]rightMatrix to multiply this one by.
Returns
New matrix containing the result.
MMatrix & operator*= ( double  factor)

The in place matrix multiply by a scalar operator.

Modifies this matrix.

Parameters
[in]factorScalar to multiply this matrix by.
Returns
This matrix.
MMatrix operator* ( double  factor) const

The matrix multiply by a scalar operator.

Does not modify this matrix.

Parameters
[in]factorScalar to multiply this matrix by.
Returns
New matrix containing the result.
bool operator== ( const MMatrix other) const

The matrix equality operator.

The matrices must be identical.

Parameters
[in]otherMatrix to compare against.
Returns
True if other contains the same values as this matrix, false otherwise.
bool operator!= ( const MMatrix other) const

The matrix inequality operator.

Parameters
[in]otherMatrix to compare against.
Returns
False if other contains the same values as this matrix, true otherwise.
MMatrix adjoint ( ) const

Compute and return the adjoint of this instance.

Returns
The adjoint of this matrix
MMatrix homogenize ( ) const

Compute and return a homogenized version of this instance.

Returns
The homogenized matrix
double det4x4 ( ) const

Compute and return the determinant of this instance.

Returns
The determinant
double det3x3 ( ) const

Compute and return the determinant of the upper left 3x3 submatrix of this instance.

Returns
The determinant
Examples:
gpuCache/gpuCacheCmd.cpp, gpuCache/gpuCacheDrawOverride.cpp, and gpuCache/gpuCacheSample.h.
bool isEquivalent ( const MMatrix other,
double  tolerance = MMatrix_kTol 
) const

Determine if the given matrix is equivalent to this instance within the specified tolerance.

Parameters
[in]otherthe matrix to compare to
[in]tolerancethe tolerance to use during the comparison
Returns
True if the matrices are equivalent and false otherwise
Examples:
geometrytools.cpp, and gpuCache/gpuCacheCmd.cpp.
bool isSingular ( ) const

Determines if the given matrix is singular.

Returns
True if the matrix is singular and false otherwise
double & operator() ( unsigned int  row,
unsigned int  col 
)
inline

NO SCRIPT SUPPORT.

Index operator.

Given row and column indices, it will return the value at the specified location in the matrix.

Parameters
[in]rowindex of the row to access
[in]colindex of the column to access
Returns
  • the value at the specified location in the matrix.
double * operator[] ( unsigned int  row)
inline

NO SCRIPT SUPPORT.

Index operator.

Returns an entire row of the matrix as an array of doubles.

Parameters
[in]rowindex of the row to access
Returns
  • double array containing the values of the specified row
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

Friends And Related Function Documentation

OPENMAYA_EXPORT MMatrix operator* ( double  factor,
const MMatrix right 
)
friend

NO SCRIPT SUPPORT.

Does not modify this matrix.

Parameters
[in]factorScalar to multiply this matrix by.
[in]rightThis matrix.
Returns
New matrix containing the result.
OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  os,
const MMatrix m 
)
friend

NO SCRIPT SUPPORT.

The format used is [[r11, r12, r13, r14] [r21, r22, r23, r24] [r31, r32, r33, r34] [r41, r42, r43, r44]].

Parameters
[in]osthe ostream to print to
[in]mthe MMatrix whose value is to be printed
Returns
Reference to output stream (os) to allow chaining of operations.

The documentation for this class was generated from the following files: