Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Static Protected Attributes | Friends | List of all members
G3D::Matrix3 Class Reference

A 3x3 matrix. More...

Public Member Functions

 Matrix3 (const Any &any)
 Must be in one of the following forms: More...
 
 Matrix3 (DoNotInitialize dni)
 
 Matrix3 ()
 Initial values are undefined for performance. More...
 
 Matrix3 (class BinaryInput &b)
 
 Matrix3 (const float aafEntry[3][3])
 
 Matrix3 (const Matrix3 &rkMatrix)
 
 Matrix3 (float fEntry00, float fEntry01, float fEntry02, float fEntry10, float fEntry11, float fEntry12, float fEntry20, float fEntry21, float fEntry22)
 
 Matrix3 (const class Quat &q)
 Constructs a matrix from a quaternion. More...
 
Vector3 column (int c) const
 
void deserialize (class BinaryInput &b)
 
float determinant () const
 
float diffOneNorm (const Matrix3 &y) const
 
void eigenSolveSymmetric (float afEigenvalue[3], Vector3 akEigenvector[3]) const
 eigensolver, matrix must be symmetric More...
 
float frobeniusNorm () const
 
bool fuzzyEq (const Matrix3 &b) const
 
bool inverse (Matrix3 &rkInverse, float fTolerance=1e-06) const
 
Matrix3 inverse (float fTolerance=1e-06) const
 
bool is3DRotationDilation () const
 Returns true if the rows are orthogonal, have the same length, and the determinant is greater than zero. More...
 
bool isOrthonormal () const
 Returns true if the rows and column L2 norms are 1.0 and the rows are orthogonal. More...
 
bool isRightHanded () const
 Returns true if column(0).cross(column(1)).dot(column(2)) > 0. More...
 
float l1Norm () const
 
float lInfNorm () const
 
 operator const float * () const
 
 operator float * ()
 
bool operator!= (const Matrix3 &rkMatrix) const
 
Matrix3 operator* (const Matrix3 &rkMatrix) const
 Matrix-matrix multiply. More...
 
Vector3 operator* (const Vector3 &v) const
 matrix * vector [3x3 * 3x1 = 3x1] More...
 
Matrix3 operator* (float fScalar) const
 matrix * scalar More...
 
Matrix3operator*= (const Matrix3 &rkMatrix)
 Matrix-matrix multiply. More...
 
Matrix3operator*= (float k)
 
Matrix3 operator+ (const Matrix3 &rkMatrix) const
 
Matrix3operator+= (const Matrix3 &rkMatrix)
 
Matrix3 operator- (const Matrix3 &rkMatrix) const
 
Matrix3 operator- () const
 
Matrix3operator-= (const Matrix3 &rkMatrix)
 
Matrix3operator/= (float k)
 
Matrix3operator= (const Matrix3 &rkMatrix)
 
bool operator== (const Matrix3 &rkMatrix) const
 
float * operator[] (int iRow)
 
Member access, allows use of construct mat[r][c] More...
 
const float * operator[] (int iRow) const
 
void orthonormalize ()
 Gram-Schmidt orthonormalization (applied to columns of rotation matrix) More...
 
void polarDecomposition (Matrix3 &R, Matrix3 &S) const
 Polar decomposition of a matrix. More...
 
void qDUDecomposition (Matrix3 &rkQ, Vector3 &rkD, Vector3 &rkU) const
 orthogonal Q, diagonal D, upper triangular U stored as (u01,u02,u12) More...
 
const Vector3row (int r) const
 
void serialize (class BinaryOutput &b) const
 
void set (float fEntry00, float fEntry01, float fEntry02, float fEntry10, float fEntry11, float fEntry12, float fEntry20, float fEntry21, float fEntry22)
 
Sets all elements. More...
 
void setColumn (int iCol, const Vector3 &vector)
 
void setRow (int iRow, const Vector3 &vector)
 
void singularValueComposition (const Matrix3 &rkL, const Vector3 &rkS, const Matrix3 &rkR)
 singular value decomposition More...
 
void singularValueDecomposition (Matrix3 &rkL, Vector3 &rkS, Matrix3 &rkR) const
 singular value decomposition More...
 
float spectralNorm () const
 Matrix norms. More...
 
float squaredFrobeniusNorm () const
 
Any toAny () const
 
void toAxisAngle (Vector3 &rkAxis, float &rfRadians) const
 matrix must be orthonormal More...
 
bool toEulerAnglesXYZ (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 The matrix must be orthonormal. More...
 
bool toEulerAnglesXZY (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 
bool toEulerAnglesYXZ (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 
bool toEulerAnglesYZX (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 
bool toEulerAnglesZXY (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 
bool toEulerAnglesZYX (float &rfYAngle, float &rfPAngle, float &rfRAngle) const
 
String toString () const
 
Matrix3 transpose () const
 

Static Public Member Functions

static Matrix3 diagonal (float e00, float e11, float e22)
 
static Matrix3 fromAxisAngle (const Vector3 &rkAxis, float fRadians)
 
static Matrix3 fromColumns (const Vector3 &c0, const Vector3 &c1, const Vector3 &c2)
 
static Matrix3 fromDiagonal (const Vector3 &d)
 
static Matrix3 fromEulerAnglesXYZ (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromEulerAnglesXZY (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromEulerAnglesYXZ (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromEulerAnglesYZX (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromEulerAnglesZXY (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromEulerAnglesZYX (float fYAngle, float fPAngle, float fRAngle)
 
static Matrix3 fromRows (const Vector3 &r0, const Vector3 &r1, const Vector3 &r2)
 
static Matrix3 fromUnitAxisAngle (const Vector3 &rkAxis, float fRadians)
 Assumes that rkAxis has unit length. More...
 
static const Matrix3identity ()
 
static void mul (const Matrix3 &A, const Matrix3 &B, Matrix3 &out)
 Optimized implementation of out = A * B. More...
 
static void tensorProduct (const Vector3 &rkU, const Vector3 &rkV, Matrix3 &rkProduct)
 
static void transpose (const Matrix3 &A, Matrix3 &out)
 Optimized implementation of out = A.transpose(). More...
 
static const Matrix3zero ()
 

Static Public Attributes

static const float EPSILON
 

Protected Member Functions

bool qLAlgorithm (float afDiag[3], float afSubDiag[3])
 
void tridiagonal (float afDiag[3], float afSubDiag[3])
 

Static Protected Member Functions

static void bidiagonalize (Matrix3 &kA, Matrix3 &kL, Matrix3 &kR)
 
static void golubKahanStep (Matrix3 &kA, Matrix3 &kL, Matrix3 &kR)
 
static float maxCubicRoot (float afCoeff[3])
 

Static Protected Attributes

static const float ms_fSvdEpsilon
 
static const int ms_iSvdMaxIterations
 

Friends

Vector3 operator* (const Vector3 &rkVector, const Matrix3 &rkMatrix)
 vector * matrix [1x3 * 3x3 = 1x3] More...
 
Matrix3 operator* (double fScalar, const Matrix3 &rkMatrix)
 scalar * matrix More...
 
Matrix3 operator* (float fScalar, const Matrix3 &rkMatrix)
 
Matrix3 operator* (int fScalar, const Matrix3 &rkMatrix)
 

Detailed Description

A 3x3 matrix.

Do not subclass. Data is unitializd when default constructed.

Constructor & Destructor Documentation

◆ Matrix3() [1/8]

G3D::Matrix3::Matrix3 ( const Any any)

Must be in one of the following forms:

◆ Matrix3() [2/8]

G3D::Matrix3::Matrix3 ( DoNotInitialize  dni)
inline

◆ Matrix3() [3/8]

G3D::Matrix3::Matrix3 ( )
inline

Initial values are undefined for performance.

See also
Matrix3::zero, Matrix3::identity, Matrix3::fromAxisAngle, etc.

Referenced by diagonal(), and fromDiagonal().

◆ Matrix3() [4/8]

G3D::Matrix3::Matrix3 ( class BinaryInput b)

◆ Matrix3() [5/8]

G3D::Matrix3::Matrix3 ( const float  aafEntry[3][3])

◆ Matrix3() [6/8]

G3D::Matrix3::Matrix3 ( const Matrix3 rkMatrix)

◆ Matrix3() [7/8]

G3D::Matrix3::Matrix3 ( float  fEntry00,
float  fEntry01,
float  fEntry02,
float  fEntry10,
float  fEntry11,
float  fEntry12,
float  fEntry20,
float  fEntry21,
float  fEntry22 
)

◆ Matrix3() [8/8]

G3D::Matrix3::Matrix3 ( const class Quat q)

Constructs a matrix from a quaternion.

Referenced Code: Graphics Gems II, p. 351–354
Referenced Code: Implementation from Watt and Watt, pg 362

Member Function Documentation

◆ bidiagonalize()

static void G3D::Matrix3::bidiagonalize ( Matrix3 kA,
Matrix3 kL,
Matrix3 kR 
)
staticprotected

◆ column()

Vector3 G3D::Matrix3::column ( int  c) const

◆ deserialize()

void G3D::Matrix3::deserialize ( class BinaryInput b)

◆ determinant()

float G3D::Matrix3::determinant ( ) const

◆ diagonal()

static Matrix3 G3D::Matrix3::diagonal ( float  e00,
float  e11,
float  e22 
)
inlinestatic

◆ diffOneNorm()

float G3D::Matrix3::diffOneNorm ( const Matrix3 y) const

◆ eigenSolveSymmetric()

void G3D::Matrix3::eigenSolveSymmetric ( float  afEigenvalue[3],
Vector3  akEigenvector[3] 
) const

eigensolver, matrix must be symmetric

◆ frobeniusNorm()

float G3D::Matrix3::frobeniusNorm ( ) const

◆ fromAxisAngle()

static Matrix3 G3D::Matrix3::fromAxisAngle ( const Vector3 rkAxis,
float  fRadians 
)
static

◆ fromColumns()

static Matrix3 G3D::Matrix3::fromColumns ( const Vector3 c0,
const Vector3 c1,
const Vector3 c2 
)
inlinestatic

◆ fromDiagonal()

static Matrix3 G3D::Matrix3::fromDiagonal ( const Vector3 d)
inlinestatic

◆ fromEulerAnglesXYZ()

static Matrix3 G3D::Matrix3::fromEulerAnglesXYZ ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromEulerAnglesXZY()

static Matrix3 G3D::Matrix3::fromEulerAnglesXZY ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromEulerAnglesYXZ()

static Matrix3 G3D::Matrix3::fromEulerAnglesYXZ ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromEulerAnglesYZX()

static Matrix3 G3D::Matrix3::fromEulerAnglesYZX ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromEulerAnglesZXY()

static Matrix3 G3D::Matrix3::fromEulerAnglesZXY ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromEulerAnglesZYX()

static Matrix3 G3D::Matrix3::fromEulerAnglesZYX ( float  fYAngle,
float  fPAngle,
float  fRAngle 
)
static

◆ fromRows()

static Matrix3 G3D::Matrix3::fromRows ( const Vector3 r0,
const Vector3 r1,
const Vector3 r2 
)
inlinestatic

◆ fromUnitAxisAngle()

static Matrix3 G3D::Matrix3::fromUnitAxisAngle ( const Vector3 rkAxis,
float  fRadians 
)
static

Assumes that rkAxis has unit length.

◆ fuzzyEq()

bool G3D::Matrix3::fuzzyEq ( const Matrix3 b) const

◆ golubKahanStep()

static void G3D::Matrix3::golubKahanStep ( Matrix3 kA,
Matrix3 kL,
Matrix3 kR 
)
staticprotected

◆ identity()

static const Matrix3& G3D::Matrix3::identity ( )
static

◆ inverse() [1/2]

bool G3D::Matrix3::inverse ( Matrix3 rkInverse,
float  fTolerance = 1e-06 
) const

◆ inverse() [2/2]

Matrix3 G3D::Matrix3::inverse ( float  fTolerance = 1e-06) const

◆ is3DRotationDilation()

bool G3D::Matrix3::is3DRotationDilation ( ) const

Returns true if the rows are orthogonal, have the same length, and the determinant is greater than zero.

◆ isOrthonormal()

bool G3D::Matrix3::isOrthonormal ( ) const

Returns true if the rows and column L2 norms are 1.0 and the rows are orthogonal.

◆ isRightHanded()

bool G3D::Matrix3::isRightHanded ( ) const

Returns true if column(0).cross(column(1)).dot(column(2)) > 0.

◆ l1Norm()

float G3D::Matrix3::l1Norm ( ) const

◆ lInfNorm()

float G3D::Matrix3::lInfNorm ( ) const

◆ maxCubicRoot()

static float G3D::Matrix3::maxCubicRoot ( float  afCoeff[3])
staticprotected

◆ mul()

static void G3D::Matrix3::mul ( const Matrix3 A,
const Matrix3 B,
Matrix3 out 
)
inlinestatic

Optimized implementation of out = A * B.

It is safe (but slow) to call with A, B, and out possibly pointer equal to one another.

◆ operator const float *()

G3D::Matrix3::operator const float * ( ) const
inline

◆ operator float *()

G3D::Matrix3::operator float * ( )
inline

◆ operator!=()

bool G3D::Matrix3::operator!= ( const Matrix3 rkMatrix) const

◆ operator*() [1/3]

Matrix3 G3D::Matrix3::operator* ( const Matrix3 rkMatrix) const

Matrix-matrix multiply.

◆ operator*() [2/3]

Vector3 G3D::Matrix3::operator* ( const Vector3 v) const
inline

matrix * vector [3x3 * 3x1 = 3x1]

◆ operator*() [3/3]

Matrix3 G3D::Matrix3::operator* ( float  fScalar) const

matrix * scalar

◆ operator*=() [1/2]

Matrix3& G3D::Matrix3::operator*= ( const Matrix3 rkMatrix)

Matrix-matrix multiply.

◆ operator*=() [2/2]

Matrix3& G3D::Matrix3::operator*= ( float  k)

◆ operator+()

Matrix3 G3D::Matrix3::operator+ ( const Matrix3 rkMatrix) const

◆ operator+=()

Matrix3& G3D::Matrix3::operator+= ( const Matrix3 rkMatrix)

◆ operator-() [1/2]

Matrix3 G3D::Matrix3::operator- ( const Matrix3 rkMatrix) const

◆ operator-() [2/2]

Matrix3 G3D::Matrix3::operator- ( ) const

◆ operator-=()

Matrix3& G3D::Matrix3::operator-= ( const Matrix3 rkMatrix)

◆ operator/=()

Matrix3& G3D::Matrix3::operator/= ( float  k)

◆ operator=()

Matrix3& G3D::Matrix3::operator= ( const Matrix3 rkMatrix)
inline

◆ operator==()

bool G3D::Matrix3::operator== ( const Matrix3 rkMatrix) const

◆ operator[]() [1/2]

float* G3D::Matrix3::operator[] ( int  iRow)
inline


Member access, allows use of construct mat[r][c]

◆ operator[]() [2/2]

const float* G3D::Matrix3::operator[] ( int  iRow) const
inline

◆ orthonormalize()

void G3D::Matrix3::orthonormalize ( )

Gram-Schmidt orthonormalization (applied to columns of rotation matrix)

◆ polarDecomposition()

void G3D::Matrix3::polarDecomposition ( Matrix3 R,
Matrix3 S 
) const

Polar decomposition of a matrix.

Based on pseudocode from Nicholas J Higham, "Computing the Polar Decomposition – with Applications Siam Journal of Science and Statistical Computing, Vol 7, No. 4, October 1986.

Decomposes A into R*S, where R is orthogonal and S is symmetric.

Ken Shoemake's "Matrix animation and polar decomposition" in Proceedings of the conference on Graphics interface '92 seems to be better known in the world of graphics, but Higham's version uses a scaling constant that can lead to faster convergence than Shoemake's when the initial matrix is far from orthogonal.

◆ qDUDecomposition()

void G3D::Matrix3::qDUDecomposition ( Matrix3 rkQ,
Vector3 rkD,
Vector3 rkU 
) const

orthogonal Q, diagonal D, upper triangular U stored as (u01,u02,u12)

◆ qLAlgorithm()

bool G3D::Matrix3::qLAlgorithm ( float  afDiag[3],
float  afSubDiag[3] 
)
protected

◆ row()

const Vector3& G3D::Matrix3::row ( int  r) const

◆ serialize()

void G3D::Matrix3::serialize ( class BinaryOutput b) const

◆ set()

void G3D::Matrix3::set ( float  fEntry00,
float  fEntry01,
float  fEntry02,
float  fEntry10,
float  fEntry11,
float  fEntry12,
float  fEntry20,
float  fEntry21,
float  fEntry22 
)


Sets all elements.

◆ setColumn()

void G3D::Matrix3::setColumn ( int  iCol,
const Vector3 vector 
)

◆ setRow()

void G3D::Matrix3::setRow ( int  iRow,
const Vector3 vector 
)

◆ singularValueComposition()

void G3D::Matrix3::singularValueComposition ( const Matrix3 rkL,
const Vector3 rkS,
const Matrix3 rkR 
)

singular value decomposition

◆ singularValueDecomposition()

void G3D::Matrix3::singularValueDecomposition ( Matrix3 rkL,
Vector3 rkS,
Matrix3 rkR 
) const

singular value decomposition

◆ spectralNorm()

float G3D::Matrix3::spectralNorm ( ) const

Matrix norms.

◆ squaredFrobeniusNorm()

float G3D::Matrix3::squaredFrobeniusNorm ( ) const

◆ tensorProduct()

static void G3D::Matrix3::tensorProduct ( const Vector3 rkU,
const Vector3 rkV,
Matrix3 rkProduct 
)
static

◆ toAny()

Any G3D::Matrix3::toAny ( ) const

◆ toAxisAngle()

void G3D::Matrix3::toAxisAngle ( Vector3 rkAxis,
float &  rfRadians 
) const

matrix must be orthonormal

◆ toEulerAnglesXYZ()

bool G3D::Matrix3::toEulerAnglesXYZ ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

The matrix must be orthonormal.

The decomposition is yaw*pitch*roll where yaw is rotation about the Up vector, pitch is rotation about the right axis, and roll is rotation about the Direction axis.

◆ toEulerAnglesXZY()

bool G3D::Matrix3::toEulerAnglesXZY ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

◆ toEulerAnglesYXZ()

bool G3D::Matrix3::toEulerAnglesYXZ ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

◆ toEulerAnglesYZX()

bool G3D::Matrix3::toEulerAnglesYZX ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

◆ toEulerAnglesZXY()

bool G3D::Matrix3::toEulerAnglesZXY ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

◆ toEulerAnglesZYX()

bool G3D::Matrix3::toEulerAnglesZYX ( float &  rfYAngle,
float &  rfPAngle,
float &  rfRAngle 
) const

◆ toString()

String G3D::Matrix3::toString ( ) const

◆ transpose() [1/2]

static void G3D::Matrix3::transpose ( const Matrix3 A,
Matrix3 out 
)
inlinestatic

Optimized implementation of out = A.transpose().

It is safe (but slow) to call with A and out possibly pointer equal to one another.

Note that A.transpose() * v can be computed more efficiently as v * A.

Referenced by G3D::CoordinateFrame::inverse(), and transpose().

◆ transpose() [2/2]

Matrix3 G3D::Matrix3::transpose ( ) const

◆ tridiagonal()

void G3D::Matrix3::tridiagonal ( float  afDiag[3],
float  afSubDiag[3] 
)
protected

◆ zero()

static const Matrix3& G3D::Matrix3::zero ( )
static

Friends And Related Function Documentation

◆ operator* [1/4]

Vector3 operator* ( const Vector3 rkVector,
const Matrix3 rkMatrix 
)
friend

vector * matrix [1x3 * 3x3 = 1x3]

◆ operator* [2/4]

Matrix3 operator* ( double  fScalar,
const Matrix3 rkMatrix 
)
friend

scalar * matrix

◆ operator* [3/4]

Matrix3 operator* ( float  fScalar,
const Matrix3 rkMatrix 
)
friend

◆ operator* [4/4]

Matrix3 operator* ( int  fScalar,
const Matrix3 rkMatrix 
)
friend

Member Data Documentation

◆ EPSILON

const float G3D::Matrix3::EPSILON
static

◆ ms_fSvdEpsilon

const float G3D::Matrix3::ms_fSvdEpsilon
staticprotected

◆ ms_iSvdMaxIterations

const int G3D::Matrix3::ms_iSvdMaxIterations
staticprotected

documentation generated on Wed Nov 24 2021 08:01:58 using doxygen 1.8.15