- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Public Attributes

# Matrix Class Reference

This reference page is linked to from the following overview topics: Math and Geometry Utilities.

Search for all occurrences

## Detailed Description

This class represents a 4x4 transformation matrix.

Definition at line 1066 of file math.h.

`#include <math.h>`

List of all members.

## Public Member Functions
| Matrix (void)
| Construct a matrix without initializing its elements. The values stored in the matrix are undefined.
| Matrix (const Matrix &m)
| Matrix (float f11, float f12, float f13, float f14, float f21, float f22, float f23, float f24, float f31, float f32, float f33, float f34, float f41, float f42, float f43, float f44)
| Construct the matrix by passing all the 16 values.
| Matrix (const double *pMatrix)
| Construct a matrix from an array of double values. At least 16 values should be contained in the array.
float & | operator() (int iRow, int iColumn)
| Returns a reference to a specific element in the matrix.
float | operator() (int iRow, int iColumn) const
| Returns the value of a specific element in the matrix.
| operator const float * (void) const
| Returns a pointer to the matrix data as a pointer to float values.
| operator float * (void)
| Returns a pointer to the constant matrix data as a pointer to float values.
Matrix & | SetIdentity (void)
| Sets this matrix to be the identity matrix.
bool | IsIdentity (void) const
| Return true if the matrix is the identity matrix.
bool | IsRigid (void) const
| Returns true if the transformation represented by the matrix is rigid (contains only translation and rotation, not scale).
Matrix & | operator*= (float)
| Multiplies the matrix with a scalar value.
Matrix | operator* (const Matrix &m) const
| Multiplies two matrices.
Matrix | operator* (float) const
| Returns the multiplication of a matrix and a scalar.
Matrix | operator+ (const Matrix &) const
| Returns the sum of two matrices.
Matrix & | operator*= (const Matrix &m)
| Multiplies the matrix with another matrix.
bool | operator== (const Matrix &m) const
| Return true if the two matrices are identical.
void | SetRow (int iRowIndex, const Vector &vValue)
| Sets the values in a row of the matrix.
Matrix & | Transpose (void)
| Transposes the matrix and returns it.
Matrix & | Invert (void)
| Inverts the matrix and returns it.
Matrix & | FromEuler (const Vector &vAngles)
| Creates a rotation matrix from the given euler values stored in the vector and returns it.
Vector | ToEuler (void) const
| Converts a rotation matrix to euler values returns them in a vector.
Matrix & | FromAxisAngle (const Vector &vAxis, float fAngle)
| Calculates a rotation matrix from an axis and angle and returns it.
Vector | Transform (const Vector &v, float fW=1.0f) const
| Transforms a vector by the matrix and returns the result.
Vector | ProjectedTransform (const Vector &v, float fW=1.0f) const
| Transforms a point (represented by a Vector) by the matrix and returns the result.
Vector | Transform (const Vector &v, float fW, float &fRW) const
| Transforms a point (represented by a Vector) by the matrix, and returns all four homogeneous coordinates.
Vector | TransformDirection (const Vector &v) const
| Transform a direction vector by the matrix.
## Public Attributes
union {
float m_fData [16]
struct {
float _11
float _12
float _13
float _14
float _21
float _22
float _23
float _24
float _31
float _32
float _33
float _34
float _41
float _42
float _43
float _44
} |
double m_fAlignDummy [8]
__m128 m_vAlignDummy [4]
}; |

## Constructor & Destructor Documentation

Matrix | ( | void |  | ) | `[inline]`

Construct a matrix without initializing its elements. The values stored in the matrix are undefined.

Definition at line 1071 of file math.h.

    {};

Matrix | ( | const Matrix & | m | ) | `[inline]`

Definition at line 1073 of file math.h.

                                  :
            _11(m._11), _12(m._12), _13(m._13), _14(m._14),
            _21(m._21), _22(m._22), _23(m._23), _24(m._24),
            _31(m._31), _32(m._32), _33(m._33), _34(m._34),
            _41(m._41), _42(m._42), _43(m._43), _44(m._44) {};

Matrix | ( | float | f11,
|  | float | f12,
|  | float | f13,
|  | float | f14,
|  | float | f21,
|  | float | f22,
|  | float | f23,
|  | float | f24,
|  | float | f31,
|  | float | f32,
|  | float | f33,
|  | float | f34,
|  | float | f41,
|  | float | f42,
|  | float | f43,
|  | float | f44
| ) |  | `[inline]`

Construct the matrix by passing all the 16 values.

Definition at line 1080 of file math.h.

                                                             :
            _11(f11), _12(f12), _13(f13), _14(f14),
            _21(f21), _22(f22), _23(f23), _24(f24),
            _31(f31), _32(f32), _33(f33), _34(f34),
            _41(f41), _42(f42), _43(f43), _44(f44) {};

Matrix | ( | const double * | pMatrix | ) |

Construct a matrix from an array of double values. At least 16 values should be contained in the array.

## Member Function Documentation

float& operator() | ( | int | iRow,
|  | int | iColumn
| ) |  | `[inline]`

Returns a reference to a specific element in the matrix.

Definition at line 1093 of file math.h.

        {
            return m_fData[iRow*4+iColumn];
        };

float operator() | ( | int | iRow,
|  | int | iColumn
| ) |  | const `[inline]`

Returns the value of a specific element in the matrix.

Definition at line 1099 of file math.h.

        {
            return m_fData[iRow*4+iColumn];
        };

operator const float * | ( | void |  | ) | const `[inline]`

Returns a pointer to the matrix data as a pointer to float values.

Do not delete this pointer.

Definition at line 1106 of file math.h.

    { return m_fData; };

operator float * | ( | void |  | ) | `[inline]`

Returns a pointer to the constant matrix data as a pointer to float values.

Definition at line 1110 of file math.h.

    { return m_fData; };

Matrix& SetIdentity | ( | void |  | ) |

Search for all occurrences

Sets this matrix to be the identity matrix.

bool IsIdentity | ( | void |  | ) | const

Search for all occurrences

Return true if the matrix is the identity matrix.

bool IsRigid | ( | void |  | ) | const

Search for all occurrences

Returns true if the transformation represented by the matrix is rigid (contains only translation and rotation, not scale).

Matrix& operator*= | ( | float |  | ) |

Multiplies the matrix with a scalar value.

Matrix operator* | ( | const Matrix & | m | ) | const

Multiplies two matrices.

Matrix operator* | ( | float |  | ) | const

Returns the multiplication of a matrix and a scalar.

Matrix operator+ | ( | const Matrix & |  | ) | const

Returns the sum of two matrices.

Matrix& operator*= | ( | const Matrix & | m | ) |

Multiplies the matrix with another matrix.

bool operator== | ( | const Matrix & | m | ) | const

Return true if the two matrices are identical.

void SetRow | ( | int | iRowIndex,
|  | const Vector & | vValue
| ) |  |

Search for all occurrences

Sets the values in a row of the matrix.

The last value in the row remains unchanged.

Matrix& Transpose | ( | void |  | ) |

Search for all occurrences

Transposes the matrix and returns it.

Matrix& Invert | ( | void |  | ) |

Search for all occurrences

Inverts the matrix and returns it.

Matrix& FromEuler | ( | const Vector & | vAngles | ) |

Search for all occurrences

Creates a rotation matrix from the given euler values stored in the vector and returns it.

Vector ToEuler | ( | void |  | ) | const

Search for all occurrences

Converts a rotation matrix to euler values returns them in a vector.

Matrix& FromAxisAngle | ( | const Vector & | vAxis,
|  | float | fAngle
| ) |  |

Search for all occurrences

Calculates a rotation matrix from an axis and angle and returns it.

Vector Transform | ( | const Vector & | v,
|  | float | fW = `1.0f`
| ) |  | const `[inline]`

Search for all occurrences

Transforms a vector by the matrix and returns the result.

The fourth component of the vector (if you are using homogeneous coordinates) can be passed in the fW parameter.

Parameters:

  [in] | v | A Vector containing the x, y, z components of the point
  [in] | fW | The w component of the point

Definition at line 1162 of file math.h.

        {
            return Vector(
                v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
                v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
                v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
        };

Vector ProjectedTransform | ( | const Vector & | v,
|  | float | fW = `1.0f`
| ) |  | const `[inline]`

Search for all occurrences

Transforms a point (represented by a Vector) by the matrix and returns the result.

This point is assumed to be represented in homogenous coordinates, with a fourth (W) value. After the transformation the result vector will be divided by the resulting W component.

Parameters:

  [in] | v | A Vector containing the x, y, z components of the point
  [in] | fW | The w component of the point

Definition at line 1177 of file math.h.

        {
            float fRW = v.m_fX*_14+v.m_fY*_24+v.m_fZ*_34+fW*_44;
            return (1/fRW)*Vector(
                v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
                v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
                v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
        };

Vector Transform | ( | const Vector & | v,
|  | float | fW,
|  | float & | fRW
| ) |  | const `[inline]`

Search for all occurrences

Transforms a point (represented by a Vector) by the matrix, and returns all four homogeneous coordinates.

Since Vectors only hold 3 coordinates, the W coordinate is passed in and out through parameters.

Parameters:

  [in] | v | A Vector containing the x, y, z components of the point
  [in] | fW | The w component of the point
  [out] | fRW | The w component of the transformed point

Definition at line 1195 of file math.h.

        {
            fRW = v.m_fX*_14+v.m_fY*_24+v.m_fZ*_34+fW*_44;
            return Vector(
                v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31+fW*_41,
                v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32+fW*_42,
                v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33+fW*_43 );
        };

Vector TransformDirection | ( | const Vector & | v | ) | const `[inline]`

Search for all occurrences

Transform a direction vector by the matrix.

Vector transformation is different than point transformation, in that it ignores the last row (translation) of the matrix during the transformation.

Definition at line 1212 of file math.h.

        {
            return Vector(
                v.m_fX*_11+v.m_fY*_21+v.m_fZ*_31,
                v.m_fX*_12+v.m_fY*_22+v.m_fZ*_32,
                v.m_fX*_13+v.m_fY*_23+v.m_fZ*_33 );
        };

## Member Data Documentation

float m_fData[16]

Search for all occurrences

Definition at line 1221 of file math.h.

float _11

Search for all occurrences

Definition at line 1223 of file math.h.

float _12

Search for all occurrences

Definition at line 1223 of file math.h.

float _13

Search for all occurrences

Definition at line 1223 of file math.h.

float _14

Search for all occurrences

Definition at line 1223 of file math.h.

float _21

Search for all occurrences

Definition at line 1224 of file math.h.

float _22

Search for all occurrences

Definition at line 1224 of file math.h.

float _23

Search for all occurrences

Definition at line 1224 of file math.h.

float _24

Search for all occurrences

Definition at line 1224 of file math.h.

float _31

Search for all occurrences

Definition at line 1225 of file math.h.

float _32

Search for all occurrences

Definition at line 1225 of file math.h.

float _33

Search for all occurrences

Definition at line 1225 of file math.h.

float _34

Search for all occurrences

Definition at line 1225 of file math.h.

float _41

Search for all occurrences

Definition at line 1226 of file math.h.

float _42

Search for all occurrences

Definition at line 1226 of file math.h.

float _43

Search for all occurrences

Definition at line 1226 of file math.h.

float _44

Search for all occurrences

Definition at line 1226 of file math.h.

double m_fAlignDummy[8]

Search for all occurrences

Definition at line 1228 of file math.h.

__m128 m_vAlignDummy[4]

Search for all occurrences

Definition at line 1230 of file math.h.

union { ... }

Search for all occurrences

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

- Mudbox/math.h

Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix
Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix Matrix