MatrixF

Engine/source/math/mMatrix.h

4x4 Matrix Class

More...

Private Attributes

m [16]

Note: Torque uses row-major matrices.

Public Static Attributes

Public Functions

MatrixF(bool identity)

Create an uninitialized matrix.

Create a matrix to rotate about origin by e.

Create a matrix to rotate about p by e.

Take inverse of matrix assuming it is affine (rotation, scale, sheer, translation only).

Add the passed delta to the matrix position.

dumpMatrix(const char * caption)
bool

Compute the inverse of the matrix.

getColumn(S32 col, Point3F * cptr)

Copy the requested column into a Point3F.

getColumn(S32 col, Point4F * cptr)

Copy the requested column into a Point4F.

Get the y axis of the matrix.

Get the position of the matrix.

Get the x axis of the matrix.

getRow(S32 row, Point3F * cptr)

Copy the specified row into a Point3F.

getRow(S32 row, Point4F * cptr)

Copy the specified row into a Point4F.

Return scale assuming scale was applied via mat.scale(s).

Get the z axis of the matrix.

Make this an identity matrix.

Invert m.

Copy the inversion of this into out matrix.

bool

Check to see if this is an affine matrix.

bool

Checks for identity matrix.

mul(Box3F & b)

Axial box -> Axial Box.

M * a -> M.

M * a -> M.

a * b -> M

a * b -> M

mul(Point4F & p)

M * p -> p (full [4x4] * [1x4])

a * M -> M

M * p -> d (assume w = 1.0f)

M * p -> p (assume w = 1.0f)

M * v -> d (assume w = 0.0f)

M * v -> v (assume w = 0.0f)

Normalize the matrix.

Allow people to get at m.

Allow people to get at m.

F32 &
operator()(S32 row, S32 col)

Convenience function to allow people to treat this like an array.

operator()(S32 row, S32 col)

M * Matrix(p) -> M.

Initialize matrix to rotate about origin by e.

Initialize matrix to rotate about p by e.

setColumn(S32 col, const Point3F & cptr)

Set the specified column from a Point3F.

setColumn(S32 col, const Point4F & cptr)

Set the specified column from a Point4F.

Initialize matrix with a cross product of p.

Set the position of the matrix.

setRow(S32 row, const Point3F & cptr)

Set the specified row from a Point3F.

setRow(S32 row, const Point4F & cptr)

Set the specified row from a Point4F.

Initialize matrix with a tensor product of p.

Swap rows and columns.

transposeTo(F32 * matrix)

Swaps rows and columns into matrix.

Public Static Functions

idx(U32 i, U32 j)

Get the index in m to element in column i, row j.

Detailed Description

4x4 Matrix Class

This runs at F32 precision.

Public Friends

Private Attributes

F32 m [16]

Note: Torque uses row-major matrices.

Public Static Attributes

const MatrixF Identity 

Public Functions

MatrixF(bool identity)

Create an uninitialized matrix.

Parameters:

identity

If true, initialize to the identity matrix.

MatrixF(const EulerF & e)

Create a matrix to rotate about origin by e.

see:

MatrixF(const EulerF & e, const Point3F & p)

Create a matrix to rotate about p by e.

see:

add(const MatrixF & m)

affineInverse()

Take inverse of matrix assuming it is affine (rotation, scale, sheer, translation only).

displace(const Point3F & delta)

Add the passed delta to the matrix position.

dumpMatrix(const char * caption)

fullInverse()

Compute the inverse of the matrix.

Computes inverse of full 4x4 matrix. Returns false and performs no inverse if the determinant is 0.

Note: In most cases you want to use the normal inverse function. This method should be used if the matrix has something other than (0,0,0,1) in the bottom row.

getColumn(S32 col, Point3F * cptr)

Copy the requested column into a Point3F.

This drops the bottom-most row.

getColumn(S32 col, Point4F * cptr)

Copy the requested column into a Point4F.

getColumn3F(S32 col)

getColumn4F(S32 col)

getForwardVector()

Get the y axis of the matrix.

This is the 2nd column of the matrix and is normally considered the forward vector.

getPosition()

Get the position of the matrix.

This is the 4th column of the matrix.

getRightVector()

Get the x axis of the matrix.

This is the 1st column of the matrix and is normally considered the right vector.

getRow(S32 row, Point3F * cptr)

Copy the specified row into a Point3F.

Right-most item is dropped.

getRow(S32 row, Point4F * cptr)

Copy the specified row into a Point4F.

getRow3F(S32 row)

getRow4F(S32 row)

getScale()

Return scale assuming scale was applied via mat.scale(s).

getUpVector()

Get the z axis of the matrix.

This is the 3rd column of the matrix and is normally considered the up vector.

identity()

Make this an identity matrix.

inverse()

Invert m.

invertTo(MatrixF * out)

Copy the inversion of this into out matrix.

isAffine()

Check to see if this is an affine matrix.

isIdentity()

Checks for identity matrix.

mul(Box3F & b)

Axial box -> Axial Box.

mul(const F32 a)

M * a -> M.

mul(const MatrixF & a)

M * a -> M.

mul(const MatrixF & a, const F32 b)

a * b -> M

mul(const MatrixF & a, const MatrixF & b)

a * b -> M

mul(Point4F & p)

M * p -> p (full [4x4] * [1x4])

mulL(const MatrixF & a)

a * M -> M

mulP(const Point3F & p, Point3F * d)

M * p -> d (assume w = 1.0f)

mulP(Point3F & p)

M * p -> p (assume w = 1.0f)

mulV(const VectorF & p, Point3F * d)

M * v -> d (assume w = 0.0f)

mulV(VectorF & p)

M * v -> v (assume w = 0.0f)

normalize()

Normalize the matrix.

operator const F32*()

Allow people to get at m.

operator F32*()

Allow people to get at m.

operator()(S32 row, S32 col)

Convenience function to allow people to treat this like an array.

operator()(S32 row, S32 col)

operator*=(const MatrixF & m)

scale(const Point3F & s)

M * Matrix(p) -> M.

scale(F32 s)

set(const EulerF & e)

Initialize matrix to rotate about origin by e.

set(const EulerF & e, const Point3F & p)

Initialize matrix to rotate about p by e.

setColumn(S32 col, const Point3F & cptr)

Set the specified column from a Point3F.

The bottom-most row is not set.

setColumn(S32 col, const Point4F & cptr)

Set the specified column from a Point4F.

setCrossProduct(const Point3F & p)

Initialize matrix with a cross product of p.

setPosition(const Point3F & pos)

Set the position of the matrix.

This is the 4th column of the matrix.

setRow(S32 row, const Point3F & cptr)

Set the specified row from a Point3F.

The right-most item is not set.

setRow(S32 row, const Point4F & cptr)

Set the specified row from a Point4F.

setTensorProduct(const Point3F & p, const Point3F & q)

Initialize matrix with a tensor product of p.

toEuler()

transpose()

Swap rows and columns.

transposeTo(F32 * matrix)

Swaps rows and columns into matrix.

Public Static Functions

idx(U32 i, U32 j)

Get the index in m to element in column i, row j.

This is necessary as we have m as a one dimensional array.

Parameters:

i

Column desired.

j

Row desired.