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

Stores a 3x3 matrix of double elements. More...

Public Types

typedef double ScalarType
 

Public Member Functions

 GfMatrix3d ()=default
 Default constructor. Leaves the matrix component values undefined. More...
 
 GfMatrix3d (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 Constructor. More...
 
 GfMatrix3d (const double m[3][3])
 Constructor. More...
 
 GfMatrix3d (double s)
 Constructor. More...
 
 GfMatrix3d (int s)
 This explicit constructor initializes the matrix to s times the identity matrix. More...
 
 GfMatrix3d (const GfVec3d &v)
 Constructor. More...
 
GF_API GfMatrix3d (const std::vector< std::vector< double > > &v)
 Constructor. More...
 
GF_API GfMatrix3d (const std::vector< std::vector< float > > &v)
 Constructor. More...
 
GF_API GfMatrix3d (const GfRotation &rot)
 Constructor. Initialize matrix from rotation. More...
 
GF_API GfMatrix3d (const GfQuatd &rot)
 Constructor. Initialize matrix from a quaternion. More...
 
GF_API GfMatrix3d (const class GfMatrix3f &m)
 This explicit constructor converts a "float" matrix to a "double" matrix. More...
 
void SetRow (int i, const GfVec3d &v)
 Sets a row of the matrix from a Vec3. More...
 
void SetColumn (int i, const GfVec3d &v)
 Sets a column of the matrix from a Vec3. More...
 
GfVec3d GetRow (int i) const
 Gets a row of the matrix as a Vec3. More...
 
GfVec3d GetColumn (int i) const
 Gets a column of the matrix as a Vec3. More...
 
GfMatrix3dSet (double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
 Sets the matrix from 9 independent double values, specified in row-major order. More...
 
GfMatrix3dSet (const double m[3][3])
 Sets the matrix from a 3x3 array of double values, specified in row-major order. More...
 
GfMatrix3dSetIdentity ()
 Sets the matrix to the identity matrix. More...
 
GfMatrix3dSetZero ()
 Sets the matrix to zero. More...
 
GF_API GfMatrix3dSetDiagonal (double s)
 Sets the matrix to s times the identity matrix. More...
 
GF_API GfMatrix3dSetDiagonal (const GfVec3d &)
 Sets the matrix to have diagonal (v[0], v[1], v[2]). More...
 
GF_API double * Get (double m[3][3]) const
 Fills a 3x3 array of double values with the values in the matrix, specified in row-major order. More...
 
double * data ()
 Returns raw access to components of matrix as an array of double values. More...
 
const double * data () const
 Returns const raw access to components of matrix as an array of double values. More...
 
double * GetArray ()
 Returns vector components as an array of double values. More...
 
const double * GetArray () const
 Returns vector components as a const array of double values. More...
 
double * operator[] (int i)
 Accesses an indexed row i of the matrix as an array of 3 double values so that standard indexing (such as m[0][1]) works correctly. More...
 
const double * operator[] (int i) const
 Accesses an indexed row i of the matrix as an array of 3 double values so that standard indexing (such as m[0][1]) works correctly. More...
 
GF_API bool operator== (const GfMatrix3d &m) const
 Tests for element-wise matrix equality. More...
 
GF_API bool operator== (const GfMatrix3f &m) const
 Tests for element-wise matrix equality. More...
 
bool operator!= (const GfMatrix3d &m) const
 Tests for element-wise matrix inequality. More...
 
bool operator!= (const GfMatrix3f &m) const
 Tests for element-wise matrix inequality. More...
 
GF_API GfMatrix3d GetTranspose () const
 Returns the transpose of the matrix. More...
 
GF_API GfMatrix3d GetInverse (double *det=NULL, double eps=0) const
 Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular. More...
 
GF_API double GetDeterminant () const
 Returns the determinant of the matrix. More...
 
GF_API bool Orthonormalize (bool issueWarning=true)
 Makes the matrix orthonormal in place. More...
 
GF_API GfMatrix3d GetOrthonormalized (bool issueWarning=true) const
 Returns an orthonormalized copy of the matrix. More...
 
GF_API double GetHandedness () const
 Returns the sign of the determinant of the matrix, i.e. More...
 
bool IsRightHanded () const
 Returns true if the vectors in the matrix form a right-handed coordinate system. More...
 
bool IsLeftHanded () const
 Returns true if the vectors in matrix form a left-handed coordinate system. More...
 
GF_API GfMatrix3doperator*= (const GfMatrix3d &m)
 Post-multiplies matrix m into this matrix. More...
 
GF_API GfMatrix3doperator*= (double)
 Multiplies the matrix by a double. More...
 
GF_API GfMatrix3doperator+= (const GfMatrix3d &m)
 Adds matrix m to this matrix. More...
 
GF_API GfMatrix3doperator-= (const GfMatrix3d &m)
 Subtracts matrix m from this matrix. More...
 
GF_API GfMatrix3dSetScale (double scaleFactor)
 Sets matrix to specify a uniform scaling by scaleFactor. More...
 
3D Transformation Utilities
GF_API GfMatrix3dSetRotate (const GfQuatd &rot)
 Sets the matrix to specify a rotation equivalent to rot. More...
 
GF_API GfMatrix3dSetRotate (const GfRotation &rot)
 Sets the matrix to specify a rotation equivalent to rot. More...
 
GF_API GfMatrix3dSetScale (const GfVec3d &scaleFactors)
 Sets the matrix to specify a nonuniform scaling in x, y, and z by the factors in vector scaleFactors. More...
 
GF_API GfRotation ExtractRotation () const
 Returns the rotation corresponding to this matrix. More...
 
GF_API GfVec3d DecomposeRotation (const GfVec3d &axis0, const GfVec3d &axis1, const GfVec3d &axis2) const
 Decompose the rotation corresponding to this matrix about 3 orthogonal axes. More...
 
GF_API GfQuaternion ExtractRotationQuaternion () const
 Returns the quaternion corresponding to this matrix. More...
 

Static Public Attributes

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

Friends

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

Detailed Description

Stores a 3x3 matrix of double 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 GfMatrix3d 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 82 of file matrix3d.h.

Constructor & Destructor Documentation

GfMatrix3d ( )
default

Default constructor. Leaves the matrix component values undefined.

GfMatrix3d ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12,
double  m20,
double  m21,
double  m22 
)
inline

Constructor.

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

Definition at line 96 of file matrix3d.h.

GfMatrix3d ( const double  m[3][3])
inline

Constructor.

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

Definition at line 106 of file matrix3d.h.

GfMatrix3d ( double  s)
inlineexplicit

Constructor.

Explicitly initializes the matrix to s times the identity matrix.

Definition at line 112 of file matrix3d.h.

GfMatrix3d ( int  s)
inlineexplicit

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

Definition at line 118 of file matrix3d.h.

GfMatrix3d ( const GfVec3d 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 124 of file matrix3d.h.

GF_API GfMatrix3d ( 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 GfMatrix3d ( 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 GfMatrix3d ( const GfRotation rot)

Constructor. Initialize matrix from rotation.

GF_API GfMatrix3d ( const GfQuatd rot)
explicit

Constructor. Initialize matrix from a quaternion.

GF_API GfMatrix3d ( const class GfMatrix3f m)
explicit

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

Member Function Documentation

double* data ( )
inline

Returns raw access to components of matrix as an array of double values.

Components are in row-major order.

Definition at line 234 of file matrix3d.h.

const double* data ( ) const
inline

Returns const raw access to components of matrix as an array of double values.

Components are in row-major order.

Definition at line 240 of file matrix3d.h.

GF_API GfVec3d DecomposeRotation ( const GfVec3d axis0,
const GfVec3d axis1,
const GfVec3d 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 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 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 double* Get ( double  m[3][3]) const

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

double* GetArray ( )
inline

Returns vector components as an array of double values.

Definition at line 245 of file matrix3d.h.

const double* GetArray ( ) const
inline

Returns vector components as a const array of double values.

Definition at line 250 of file matrix3d.h.

GfVec3d GetColumn ( int  i) const
inline

Gets a column of the matrix as a Vec3.

Definition at line 178 of file matrix3d.h.

GF_API double GetDeterminant ( ) const

Returns the determinant of the matrix.

GF_API double 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 GfMatrix3d 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 GfMatrix3d GetOrthonormalized ( bool  issueWarning = true) const

Returns an orthonormalized copy of the matrix.

GfVec3d GetRow ( int  i) const
inline

Gets a row of the matrix as a Vec3.

Definition at line 173 of file matrix3d.h.

GF_API GfMatrix3d GetTranspose ( ) const

Returns the transpose of the matrix.

bool IsLeftHanded ( ) const
inline

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

Definition at line 341 of file matrix3d.h.

bool IsRightHanded ( ) const
inline

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

Definition at line 335 of file matrix3d.h.

bool 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 286 of file matrix3d.h.

bool 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 292 of file matrix3d.h.

GF_API GfMatrix3d& operator*= ( const GfMatrix3d m)

Post-multiplies matrix m into this matrix.

GF_API GfMatrix3d& operator*= ( double  )

Multiplies the matrix by a double.

GF_API GfMatrix3d& operator+= ( const GfMatrix3d m)

Adds matrix m to this matrix.

GF_API GfMatrix3d& operator-= ( const GfMatrix3d m)

Subtracts matrix m from this matrix.

GF_API bool 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 operator== ( const GfMatrix3f m) const

Tests for element-wise matrix equality.

All elements must match exactly for matrices to be considered equal.

double* operator[] ( int  i)
inline

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

Definition at line 257 of file matrix3d.h.

const double* operator[] ( int  i) const
inline

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

Definition at line 262 of file matrix3d.h.

GF_API bool 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.

GfMatrix3d& Set ( double  m00,
double  m01,
double  m02,
double  m10,
double  m11,
double  m12,
double  m20,
double  m21,
double  m22 
)
inline

Sets the matrix from 9 independent double values, specified in row-major order.

For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 185 of file matrix3d.h.

GfMatrix3d& Set ( const double  m[3][3])
inline

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

Definition at line 196 of file matrix3d.h.

void SetColumn ( int  i,
const GfVec3d v 
)
inline

Sets a column of the matrix from a Vec3.

Definition at line 166 of file matrix3d.h.

GF_API GfMatrix3d& SetDiagonal ( double  s)

Sets the matrix to s times the identity matrix.

GF_API GfMatrix3d& SetDiagonal ( const GfVec3d )

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

GfMatrix3d& SetIdentity ( )
inline

Sets the matrix to the identity matrix.

Definition at line 210 of file matrix3d.h.

GF_API GfMatrix3d& SetRotate ( const GfQuatd rot)

Sets the matrix to specify a rotation equivalent to rot.

GF_API GfMatrix3d& SetRotate ( const GfRotation rot)

Sets the matrix to specify a rotation equivalent to rot.

void SetRow ( int  i,
const GfVec3d v 
)
inline

Sets a row of the matrix from a Vec3.

Definition at line 159 of file matrix3d.h.

GF_API GfMatrix3d& SetScale ( double  scaleFactor)

Sets matrix to specify a uniform scaling by scaleFactor.

GF_API GfMatrix3d& SetScale ( const GfVec3d scaleFactors)

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

GfMatrix3d& SetZero ( )
inline

Sets the matrix to zero.

Definition at line 215 of file matrix3d.h.

Friends And Related Function Documentation

size_t hash_value ( GfMatrix3d const &  m)
friend

Hash.

Definition at line 265 of file matrix3d.h.

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

Returns the product of a matrix and a double.

Definition at line 354 of file matrix3d.h.

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

Multiplies matrix m1 by m2.

Definition at line 396 of file matrix3d.h.

GfVec3d operator* ( const GfMatrix3d m,
const GfVec3d vec 
)
friend

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

Definition at line 410 of file matrix3d.h.

GfVec3d operator* ( const GfVec3d vec,
const GfMatrix3d m 
)
friend

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

Definition at line 417 of file matrix3d.h.

GF_API friend GfVec3f operator* ( const GfMatrix3d m,
const GfVec3f vec 
)
friend

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

Note that the return type is a GfVec3f.

GF_API friend GfVec3f operator* ( const GfVec3f vec,
const GfMatrix3d m 
)
friend

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

Note that the return type is a GfVec3f.

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

Adds matrix m2 to m1.

Definition at line 380 of file matrix3d.h.

GF_API friend GfMatrix3d operator- ( const GfMatrix3d m)
friend

Returns the unary negation of matrix m.

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

Subtracts matrix m2 from m1.

Definition at line 388 of file matrix3d.h.

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

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

Definition at line 404 of file matrix3d.h.


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