HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfMatrix3f Class Reference

#include <matrix3f.h>

Public Types

typedef float ScalarType
 

Public Member Functions

 GfMatrix3f ()=default
 
 GfMatrix3f (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
 
 GfMatrix3f (const float m[3][3])
 
 GfMatrix3f (float s)
 
 GfMatrix3f (int s)
 
 GfMatrix3f (const GfVec3f &v)
 
GF_API GfMatrix3f (const std::vector< std::vector< double > > &v)
 
GF_API GfMatrix3f (const std::vector< std::vector< float > > &v)
 
GF_API GfMatrix3f (const GfRotation &rot)
 Constructor. Initialize matrix from rotation. More...
 
GF_API GfMatrix3f (const GfQuatf &rot)
 Constructor. Initialize matrix from a quaternion. More...
 
GF_API GfMatrix3f (const class GfMatrix3d &m)
 This explicit constructor converts a "double" matrix to a "float" matrix. More...
 
void SetRow (int i, const GfVec3f &v)
 Sets a row of the matrix from a Vec3. More...
 
void SetColumn (int i, const GfVec3f &v)
 Sets a column of the matrix from a Vec3. More...
 
GfVec3f GetRow (int i) const
 Gets a row of the matrix as a Vec3. More...
 
GfVec3f GetColumn (int i) const
 Gets a column of the matrix as a Vec3. More...
 
GfMatrix3fSet (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
 
GfMatrix3fSet (const float m[3][3])
 
GfMatrix3fSetIdentity ()
 Sets the matrix to the identity matrix. More...
 
GfMatrix3fSetZero ()
 Sets the matrix to zero. More...
 
GF_API GfMatrix3fSetDiagonal (float s)
 Sets the matrix to s times the identity matrix. More...
 
GF_API GfMatrix3fSetDiagonal (const GfVec3f &)
 Sets the matrix to have diagonal (v[0], v[1], v[2]). More...
 
GF_API floatGet (float m[3][3]) const
 
floatdata ()
 
const floatdata () const
 
floatGetArray ()
 Returns vector components as an array of float values. More...
 
const floatGetArray () const
 Returns vector components as a const array of float values. More...
 
floatoperator[] (int i)
 
const floatoperator[] (int i) const
 
GF_API bool operator== (const GfMatrix3d &m) const
 
GF_API bool operator== (const GfMatrix3f &m) const
 
bool operator!= (const GfMatrix3d &m) const
 
bool operator!= (const GfMatrix3f &m) const
 
GF_API GfMatrix3f GetTranspose () const
 Returns the transpose of the matrix. More...
 
GF_API GfMatrix3f GetInverse (double *det=NULL, double eps=0) const
 
GF_API double GetDeterminant () const
 Returns the determinant of the matrix. More...
 
GF_API bool Orthonormalize (bool issueWarning=true)
 
GF_API GfMatrix3f GetOrthonormalized (bool issueWarning=true) const
 Returns an orthonormalized copy of the matrix. More...
 
GF_API double GetHandedness () const
 
bool IsRightHanded () const
 
bool IsLeftHanded () const
 
GF_API GfMatrix3foperator*= (const GfMatrix3f &m)
 Post-multiplies matrix m into this matrix. More...
 
GF_API GfMatrix3foperator*= (double)
 Multiplies the matrix by a float. More...
 
GF_API GfMatrix3foperator+= (const GfMatrix3f &m)
 Adds matrix m to this matrix. More...
 
GF_API GfMatrix3foperator-= (const GfMatrix3f &m)
 Subtracts matrix m from this matrix. More...
 
GF_API GfMatrix3fSetScale (float scaleFactor)
 Sets matrix to specify a uniform scaling by scaleFactor. More...
 
3D Transformation Utilities
GF_API GfMatrix3fSetRotate (const GfQuatf &rot)
 Sets the matrix to specify a rotation equivalent to rot. More...
 
GF_API GfMatrix3fSetRotate (const GfRotation &rot)
 Sets the matrix to specify a rotation equivalent to rot. More...
 
GF_API GfMatrix3fSetScale (const GfVec3f &scaleFactors)
 
GF_API GfRotation ExtractRotation () const
 
GF_API GfVec3f DecomposeRotation (const GfVec3f &axis0, const GfVec3f &axis1, const GfVec3f &axis2) const
 
GF_API GfQuaternion ExtractRotationQuaternion () const
 

Static Public Attributes

static const size_t numRows = 3
 
static const size_t numColumns = 3
 

Friends

class GfMatrix3d
 
size_t hash_value (GfMatrix3f const &m)
 Hash. More...
 
GfMatrix3f operator* (const GfMatrix3f &m1, double d)
 Returns the product of a matrix and a float. More...
 
GfMatrix3f operator* (double d, const GfMatrix3f &m)
 
GF_API friend GfMatrix3f operator- (const GfMatrix3f &m)
 Returns the unary negation of matrix m. More...
 
GfMatrix3f operator+ (const GfMatrix3f &m1, const GfMatrix3f &m2)
 Adds matrix m2 to m1. More...
 
GfMatrix3f operator- (const GfMatrix3f &m1, const GfMatrix3f &m2)
 Subtracts matrix m2 from m1. More...
 
GfMatrix3f operator* (const GfMatrix3f &m1, const GfMatrix3f &m2)
 Multiplies matrix m1 by m2. More...
 
GfMatrix3f operator/ (const GfMatrix3f &m1, const GfMatrix3f &m2)
 Divides matrix m1 by m2 (that is, m1 * inv(m2)). More...
 
GfVec3f operator* (const GfMatrix3f &m, const GfVec3f &vec)
 Returns the product of a matrix m and a column vector vec. More...
 
GfVec3f operator* (const GfVec3f &vec, const GfMatrix3f &m)
 Returns the product of row vector vec and a matrix m. More...
 

Detailed Description

Stores a 3x3 matrix of float elements. A basic type.

Matrices are defined to be in row-major order, so matrix[i][j] indexes the element in the i th row and the j th column.

3D Transformations

Three methods, SetRotate(), SetScale(), and ExtractRotation(), interpret a GfMatrix3f as a 3D transformation. By convention, vectors are treated primarily as row vectors, implying the following:

  • Transformation matrices are organized to deal with row vectors, not column vectors.
  • Each of the Set() methods in this class completely rewrites the matrix; for example, SetRotate() yields a matrix which does nothing but rotate.
  • When multiplying two transformation matrices, the matrix on the left applies a more local transformation to a row vector. For example, if R represents a rotation matrix and S represents a scale matrix, the product R*S will rotate a row vector, then scale it.

Definition at line 64 of file matrix3f.h.

Member Typedef Documentation

Definition at line 67 of file matrix3f.h.

Constructor & Destructor Documentation

GfMatrix3f::GfMatrix3f ( )
default

GfMatrix3f value-initializes to zero and performs no default initialization, like float or double.

GfMatrix3f::GfMatrix3f ( float  m00,
float  m01,
float  m02,
float  m10,
float  m11,
float  m12,
float  m20,
float  m21,
float  m22 
)
inline

Constructor. Initializes the matrix from 9 independent float values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 79 of file matrix3f.h.

GfMatrix3f::GfMatrix3f ( const float  m[3][3])
inline

Constructor. Initializes the matrix from a 3x3 array of float values, specified in row-major order.

Definition at line 89 of file matrix3f.h.

GfMatrix3f::GfMatrix3f ( float  s)
inlineexplicit

Constructor. Explicitly initializes the matrix to s times the identity matrix.

Definition at line 95 of file matrix3f.h.

GfMatrix3f::GfMatrix3f ( int  s)
inlineexplicit

This explicit constructor initializes the matrix to s times the identity matrix.

Definition at line 101 of file matrix3f.h.

GfMatrix3f::GfMatrix3f ( const GfVec3f v)
inlineexplicit

Constructor. Explicitly initializes the matrix to diagonal form, with the i th element on the diagonal set to v[i].

Definition at line 107 of file matrix3f.h.

GF_API GfMatrix3f::GfMatrix3f ( const std::vector< std::vector< double > > &  v)
explicit

Constructor. Initialize the matrix from a vector of vectors of double. The vector is expected to be 3x3. If it is too big, only the first 3 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

GF_API GfMatrix3f::GfMatrix3f ( const std::vector< std::vector< float > > &  v)
explicit

Constructor. Initialize the matrix from a vector of vectors of float. The vector is expected to be 3x3. If it is too big, only the first 3 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

GF_API GfMatrix3f::GfMatrix3f ( const GfRotation rot)

Constructor. Initialize matrix from rotation.

GF_API GfMatrix3f::GfMatrix3f ( const GfQuatf rot)
explicit

Constructor. Initialize matrix from a quaternion.

GF_API GfMatrix3f::GfMatrix3f ( const class GfMatrix3d m)
explicit

This explicit constructor converts a "double" matrix to a "float" matrix.

Member Function Documentation

float* GfMatrix3f::data ( )
inline

Returns raw access to components of matrix as an array of float values. Components are in row-major order.

Definition at line 217 of file matrix3f.h.

const float* GfMatrix3f::data ( ) const
inline

Returns const raw access to components of matrix as an array of float values. Components are in row-major order.

Definition at line 223 of file matrix3f.h.

GF_API GfVec3f GfMatrix3f::DecomposeRotation ( const GfVec3f axis0,
const GfVec3f axis1,
const GfVec3f axis2 
) const

Decompose the rotation corresponding to this matrix about 3 orthogonal axes. If the axes are not orthogonal, warnings will be spewed.

This is a convenience method that is equivalent to calling ExtractRotation().Decompose().

GF_API GfRotation GfMatrix3f::ExtractRotation ( ) const

Returns the rotation corresponding to this matrix. This works well only if the matrix represents a rotation.

For good results, consider calling Orthonormalize() before calling this method.

GF_API GfQuaternion GfMatrix3f::ExtractRotationQuaternion ( ) const

Returns the quaternion corresponding to this matrix. This works well only if the matrix represents a rotation.

For good results, consider calling Orthonormalize() before calling this method.

GF_API float* GfMatrix3f::Get ( float  m[3][3]) const

Fills a 3x3 array of float values with the values in the matrix, specified in row-major order.

float* GfMatrix3f::GetArray ( )
inline

Returns vector components as an array of float values.

Definition at line 228 of file matrix3f.h.

const float* GfMatrix3f::GetArray ( ) const
inline

Returns vector components as a const array of float values.

Definition at line 233 of file matrix3f.h.

GfVec3f GfMatrix3f::GetColumn ( int  i) const
inline

Gets a column of the matrix as a Vec3.

Definition at line 161 of file matrix3f.h.

GF_API double GfMatrix3f::GetDeterminant ( ) const

Returns the determinant of the matrix.

GF_API double GfMatrix3f::GetHandedness ( ) const

Returns the sign of the determinant of the matrix, i.e. 1 for a right-handed matrix, -1 for a left-handed matrix, and 0 for a singular matrix.

GF_API GfMatrix3f GfMatrix3f::GetInverse ( double *  det = NULL,
double  eps = 0 
) const

Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular. (FLT_MAX is the largest value a float can have, as defined by the system.) The matrix is considered singular if the determinant is less than or equal to the optional parameter eps. If det is non-null, *det is set to the determinant.

GF_API GfMatrix3f GfMatrix3f::GetOrthonormalized ( bool  issueWarning = true) const

Returns an orthonormalized copy of the matrix.

GfVec3f GfMatrix3f::GetRow ( int  i) const
inline

Gets a row of the matrix as a Vec3.

Definition at line 156 of file matrix3f.h.

GF_API GfMatrix3f GfMatrix3f::GetTranspose ( ) const

Returns the transpose of the matrix.

bool GfMatrix3f::IsLeftHanded ( ) const
inline

Returns true if the vectors in matrix form a left-handed coordinate system.

Definition at line 329 of file matrix3f.h.

bool GfMatrix3f::IsRightHanded ( ) const
inline

Returns true if the vectors in the matrix form a right-handed coordinate system.

Definition at line 323 of file matrix3f.h.

bool GfMatrix3f::operator!= ( const GfMatrix3d m) const
inline

Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.

Definition at line 274 of file matrix3f.h.

bool GfMatrix3f::operator!= ( const GfMatrix3f m) const
inline

Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.

Definition at line 280 of file matrix3f.h.

GF_API GfMatrix3f& GfMatrix3f::operator*= ( const GfMatrix3f m)

Post-multiplies matrix m into this matrix.

GF_API GfMatrix3f& GfMatrix3f::operator*= ( double  )

Multiplies the matrix by a float.

GF_API GfMatrix3f& GfMatrix3f::operator+= ( const GfMatrix3f m)

Adds matrix m to this matrix.

GF_API GfMatrix3f& GfMatrix3f::operator-= ( const GfMatrix3f m)

Subtracts matrix m from this matrix.

GF_API bool GfMatrix3f::operator== ( const GfMatrix3d m) const

Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.

GF_API bool GfMatrix3f::operator== ( const GfMatrix3f m) const

Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.

float* GfMatrix3f::operator[] ( int  i)
inline

Accesses an indexed row i of the matrix as an array of 3 float values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 240 of file matrix3f.h.

const float* GfMatrix3f::operator[] ( int  i) const
inline

Accesses an indexed row i of the matrix as an array of 3 float values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 245 of file matrix3f.h.

GF_API bool GfMatrix3f::Orthonormalize ( bool  issueWarning = true)

Makes the matrix orthonormal in place. This is an iterative method that is much more stable than the previous cross/cross method. If the iterative method does not converge, a warning is issued.

Returns true if the iteration converged, false otherwise. Leaves any translation part of the matrix unchanged. If issueWarning is true, this method will issue a warning if the iteration does not converge, otherwise it will be silent.

GfMatrix3f& GfMatrix3f::Set ( float  m00,
float  m01,
float  m02,
float  m10,
float  m11,
float  m12,
float  m20,
float  m21,
float  m22 
)
inline

Sets the matrix from 9 independent float values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 168 of file matrix3f.h.

GfMatrix3f& GfMatrix3f::Set ( const float  m[3][3])
inline

Sets the matrix from a 3x3 array of float values, specified in row-major order.

Definition at line 179 of file matrix3f.h.

void GfMatrix3f::SetColumn ( int  i,
const GfVec3f v 
)
inline

Sets a column of the matrix from a Vec3.

Definition at line 149 of file matrix3f.h.

GF_API GfMatrix3f& GfMatrix3f::SetDiagonal ( float  s)

Sets the matrix to s times the identity matrix.

GF_API GfMatrix3f& GfMatrix3f::SetDiagonal ( const GfVec3f )

Sets the matrix to have diagonal (v[0], v[1], v[2]).

GfMatrix3f& GfMatrix3f::SetIdentity ( )
inline

Sets the matrix to the identity matrix.

Definition at line 193 of file matrix3f.h.

GF_API GfMatrix3f& GfMatrix3f::SetRotate ( const GfQuatf rot)

Sets the matrix to specify a rotation equivalent to rot.

GF_API GfMatrix3f& GfMatrix3f::SetRotate ( const GfRotation rot)

Sets the matrix to specify a rotation equivalent to rot.

void GfMatrix3f::SetRow ( int  i,
const GfVec3f v 
)
inline

Sets a row of the matrix from a Vec3.

Definition at line 142 of file matrix3f.h.

GF_API GfMatrix3f& GfMatrix3f::SetScale ( float  scaleFactor)

Sets matrix to specify a uniform scaling by scaleFactor.

GF_API GfMatrix3f& GfMatrix3f::SetScale ( const GfVec3f scaleFactors)

Sets the matrix to specify a nonuniform scaling in x, y, and z by the factors in vector scaleFactors.

GfMatrix3f& GfMatrix3f::SetZero ( )
inline

Sets the matrix to zero.

Definition at line 198 of file matrix3f.h.

Friends And Related Function Documentation

friend class GfMatrix3d
friend

Definition at line 471 of file matrix3f.h.

size_t hash_value ( GfMatrix3f const &  m)
friend

Hash.

Definition at line 248 of file matrix3f.h.

GfMatrix3f operator* ( const GfMatrix3f m1,
double  d 
)
friend

Returns the product of a matrix and a float.

Definition at line 342 of file matrix3f.h.

GfMatrix3f operator* ( double  d,
const GfMatrix3f m 
)
friend

Definition at line 350 of file matrix3f.h.

GfMatrix3f operator* ( const GfMatrix3f m1,
const GfMatrix3f m2 
)
friend

Multiplies matrix m1 by m2.

Definition at line 384 of file matrix3f.h.

GfVec3f operator* ( const GfMatrix3f m,
const GfVec3f vec 
)
friend

Returns the product of a matrix m and a column vector vec.

Definition at line 398 of file matrix3f.h.

GfVec3f operator* ( const GfVec3f vec,
const GfMatrix3f m 
)
friend

Returns the product of row vector vec and a matrix m.

Definition at line 405 of file matrix3f.h.

GfMatrix3f operator+ ( const GfMatrix3f m1,
const GfMatrix3f m2 
)
friend

Adds matrix m2 to m1.

Definition at line 368 of file matrix3f.h.

GF_API friend GfMatrix3f operator- ( const GfMatrix3f m)
friend

Returns the unary negation of matrix m.

GfMatrix3f operator- ( const GfMatrix3f m1,
const GfMatrix3f m2 
)
friend

Subtracts matrix m2 from m1.

Definition at line 376 of file matrix3f.h.

GfMatrix3f operator/ ( const GfMatrix3f m1,
const GfMatrix3f m2 
)
friend

Divides matrix m1 by m2 (that is, m1 * inv(m2)).

Definition at line 392 of file matrix3f.h.

Member Data Documentation

const size_t GfMatrix3f::numColumns = 3
static

Definition at line 70 of file matrix3f.h.

const size_t GfMatrix3f::numRows = 3
static

Definition at line 69 of file matrix3f.h.


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