C++ API Reference
MFloatMatrix Class Reference

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

#include <MFloatMatrix.h>

Public Member Functions

 MFloatMatrix ()
 The default contstructor. More...
 
 MFloatMatrix (const MFloatMatrix &src)
 The copy Constructor. More...
 
 MFloatMatrix (const double m[4][4])
 Initialize the instance with a 4x4 matrix of doubles. More...
 
 MFloatMatrix (const float m[4][4])
 Initialize the instance with a 4x4 matrix of floats. More...
 
 ~MFloatMatrix ()
 The class destructor.
 
MFloatMatrixoperator= (const MFloatMatrix &)
 The assignment operator. More...
 
float operator() (unsigned int row, unsigned int col) const
 Index operator. More...
 
const float * 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...
 
MFloatMatrix transpose () const
 Compute and return the transpose of this instance. More...
 
MFloatMatrixsetToIdentity ()
 Set this instance to the 4x4 identity matrix. More...
 
MFloatMatrixsetToProduct (const MFloatMatrix &left, const MFloatMatrix &right)
 Set this instance to the inner product of the two argument matrices. More...
 
MFloatMatrixoperator+= (const MFloatMatrix &right)
 The in place matrix addition operator. More...
 
MFloatMatrix operator+ (const MFloatMatrix &right) const
 The matrix addition operator. More...
 
MFloatMatrixoperator-= (const MFloatMatrix &right)
 The in place matrix subtraction operator. More...
 
MFloatMatrix operator- (const MFloatMatrix &right) const
 The matrix subtraction operator. More...
 
MFloatMatrixoperator*= (const MFloatMatrix &right)
 The in place matrix multiplication operator. More...
 
MFloatMatrix operator* (const MFloatMatrix &right) const
 The matrix multiplication operator. More...
 
MFloatMatrixoperator*= (float)
 The in place matrix multiply by a scalar operator. More...
 
MFloatMatrix operator* (float) const
 The matrix multiply by a scalar operator. More...
 
bool operator== (const MFloatMatrix &other) const
 The matrix equality operator. More...
 
bool operator!= (const MFloatMatrix &other) const
 The matrix inequality operator. More...
 
MFloatMatrix inverse () const
 Compute and return the inverse of this instance. More...
 
MFloatMatrix adjoint () const
 Compute and return the adjoint of this instance. More...
 
MFloatMatrix homogenize () const
 Compute and return a homogenized version of this instance. More...
 
float det4x4 () const
 Compute and return the determinant of this instance. More...
 
float det3x3 () const
 Compute and return the determinant of the upper left 3x3 submatrix of this instance. More...
 
bool isEquivalent (const MFloatMatrix &other, float tolerance=MFloatMatrix_kTol) const
 Determine if the given matrix is equivalent to this instance within the specified tolerance. More...
 
float & operator() (unsigned int row, unsigned int col)
 NO SCRIPT SUPPORT. More...
 
float * 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

float matrix [4][4]
 the matrix data
 

Friends

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

Detailed Description

A matrix math class for 4x4 matrices of floats.

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.

Examples:
animInfoCmd/animInfoCmd.cpp, anisotropicShader/anisotropicShader.cpp, cellShader/cellShader.cpp, flameShader/flameShader.cpp, lavaShader/lavaShader.cpp, noiseShader/noiseShader.cpp, sampleCmd/sampleCmd.cpp, sampleParticles/sampleParticles.cpp, slopeShader/slopeShaderNode.cpp, and solidCheckerShader/solidCheckerShader.cpp.

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MFloatMatrix ( )

The default contstructor.

The instance is initialized to the 4x4 identity matrix.

MFloatMatrix ( const MFloatMatrix src)

The copy Constructor.

Parameters
[in]srcthe instance to copy data from
MFloatMatrix ( const double  src_matrix[4][4])

Initialize the instance with a 4x4 matrix of doubles.

Parameters
[in]src_matrixa 4x4 matrix of doubles
MFloatMatrix ( const float  src_matrix[4][4])

Initialize the instance with a 4x4 matrix of floats.

Parameters
[in]src_matrixa 4x4 matrix of floats

Member Function Documentation

MFloatMatrix & operator= ( const MFloatMatrix src)

The assignment operator.

Parameters
[in]srcThe matrix to copy from.
Returns
A reference to this matrix.
float 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 float * operator[] ( unsigned int  row) const
inline

Index operator.

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

Parameters
[in]rowindex of the row to access
Returns
  • float 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]destthe 4x4 matrix of doubles to populate
Returns
MS::kSuccess if successful and MS::kFailure otherwise.
MStatus get ( float  dest[4][4]) const

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

Parameters
[out]destThe 4x4 matrix of floats to populate.
Returns
MS::kSuccess if successful and MS::kFailure otherwise.
MFloatMatrix transpose ( ) const

Compute and return the transpose of this instance.

Returns
The transposed matrix
MFloatMatrix & setToIdentity ( )

Set this instance to the 4x4 identity matrix.

Returns
A reference to this matrix.
MFloatMatrix & setToProduct ( const MFloatMatrix left,
const MFloatMatrix 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
A reference to the result.
MFloatMatrix & operator+= ( const MFloatMatrix right)

The in place matrix addition operator.

Parameters
[in]rightMatrix to add.
Returns
A reference to the result.
MFloatMatrix operator+ ( const MFloatMatrix right) const

The matrix addition operator.

Parameters
[in]rightMatrix to add.
Returns
Sum of both matrices.
MFloatMatrix & operator-= ( const MFloatMatrix right)

The in place matrix subtraction operator.

Parameters
[in]rightMatrix to subtract.
Returns
A reference to the result.
MFloatMatrix operator- ( const MFloatMatrix right) const

The matrix subtraction operator.

Parameters
[in]rightMatrix to subtract.
Returns
Difference of both matrices.
MFloatMatrix & operator*= ( const MFloatMatrix right)

The in place matrix multiplication operator.

Parameters
[in]rightMatrix to multiply.
Returns
A reference to the result.
MFloatMatrix operator* ( const MFloatMatrix right) const

The matrix multiplication operator.

Parameters
[in]rightMatrix to multiply.
Returns
Product of both matrices.
MFloatMatrix & operator*= ( float  factor)

The in place matrix multiply by a scalar operator.

Parameters
[in]factorscaling factor.
Returns
A reference to the result.
MFloatMatrix operator* ( float  factor) const

The matrix multiply by a scalar operator.

Parameters
[in]factorScaling factor.
Returns
Scaled matrix.
bool operator== ( const MFloatMatrix other) const

The matrix equality operator.

Parameters
[in]otherMatrix to test with.
Returns
True is the matrices are identical.
bool operator!= ( const MFloatMatrix other) const

The matrix inequality operator.

Parameters
[in]otherMatrix to test with.
Returns
True is the matrices are not identical.
MFloatMatrix inverse ( ) const

Compute and return the inverse of this instance.

Returns
The inverted matrix
MFloatMatrix adjoint ( ) const

Compute and return the adjoint of this instance.

Returns
The adjoint of this matrix
MFloatMatrix homogenize ( ) const

Compute and return a homogenized version of this instance.

Returns
The homogenized matrix
float det4x4 ( ) const

Compute and return the determinant of this instance.

Returns
The determinant
float det3x3 ( ) const

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

Returns
The determinant
bool isEquivalent ( const MFloatMatrix other,
float  tolerance = MFloatMatrix_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
float & 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.
float * operator[] ( unsigned int  row)
inline

NO SCRIPT SUPPORT.

Index operator.

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

Parameters
[in]rowindex of the row to access
Returns
  • float 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 MFloatMatrix operator* ( float  factor,
const MFloatMatrix right 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]factorScaling factor.
[in]rightMatrix to multiply.
Returns
Scaled matrix.
OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  os,
const MFloatMatrix 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 MFloatMatrix whose value is to be printed
Returns
The ostream reference, s, provided as the first parameter.

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