HDK
|
#include <matrix4f.h>
Public Types | |
typedef float | ScalarType |
Public Member Functions | |
GfMatrix4f ()=default | |
Default constructor. Leaves the matrix component values undefined. More... | |
GfMatrix4f (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) | |
GfMatrix4f (const float m[4][4]) | |
GfMatrix4f (float s) | |
GfMatrix4f (const GfVec4f &v) | |
GF_API | GfMatrix4f (const std::vector< std::vector< double > > &v) |
GF_API | GfMatrix4f (const std::vector< std::vector< float > > &v) |
GF_API | GfMatrix4f (const std::vector< double > &r0, const std::vector< double > &r1, const std::vector< double > &r2, const std::vector< double > &r3) |
GF_API | GfMatrix4f (const std::vector< float > &r0, const std::vector< float > &r1, const std::vector< float > &r2, const std::vector< float > &r3) |
GF_API | GfMatrix4f (const GfRotation &rotate, const GfVec3f &translate) |
GF_API | GfMatrix4f (const GfMatrix3f &rotmx, const GfVec3f &translate) |
GF_API | GfMatrix4f (const class GfMatrix4d &m) |
This explicit constructor converts a "double" matrix to a "float" matrix. More... | |
void | SetRow (int i, const GfVec4f &v) |
Sets a row of the matrix from a Vec4. More... | |
void | SetColumn (int i, const GfVec4f &v) |
Sets a column of the matrix from a Vec4. More... | |
GfVec4f | GetRow (int i) const |
Gets a row of the matrix as a Vec4. More... | |
GfVec4f | GetColumn (int i) const |
Gets a column of the matrix as a Vec4. More... | |
GfMatrix4f & | Set (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) |
GfMatrix4f & | Set (const float m[4][4]) |
GfMatrix4f & | SetIdentity () |
Sets the matrix to the identity matrix. More... | |
GfMatrix4f & | SetZero () |
Sets the matrix to zero. More... | |
GF_API GfMatrix4f & | SetDiagonal (float s) |
Sets the matrix to s times the identity matrix. More... | |
GF_API GfMatrix4f & | SetDiagonal (const GfVec4f &) |
Sets the matrix to have diagonal (v[0], v[1], v[2], v[3] ). More... | |
GF_API float * | Get (float m[4][4]) const |
float * | data () |
const float * | data () const |
float * | GetArray () |
Returns vector components as an array of float values. More... | |
const float * | GetArray () const |
Returns vector components as a const array of float values. More... | |
float * | operator[] (int i) |
const float * | operator[] (int i) const |
GF_API bool | operator== (const GfMatrix4d &m) const |
GF_API bool | operator== (const GfMatrix4f &m) const |
bool | operator!= (const GfMatrix4d &m) const |
bool | operator!= (const GfMatrix4f &m) const |
GF_API GfMatrix4f | GetTranspose () const |
Returns the transpose of the matrix. More... | |
GF_API GfMatrix4f | GetInverse (double *det=NULL, double eps=0) const |
GF_API double | GetDeterminant () const |
Returns the determinant of the matrix. More... | |
void | SetRow3 (int i, const GfVec3f &v) |
GfVec3f | GetRow3 (int i) const |
Gets a row of the matrix as a Vec3. More... | |
double | GetDeterminant3 () const |
bool | HasOrthogonalRows3 () const |
GF_API bool | Orthonormalize (bool issueWarning=true) |
GF_API GfMatrix4f | 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 GfMatrix4f & | operator*= (const GfMatrix4f &m) |
Post-multiplies matrix m into this matrix. More... | |
GF_API GfMatrix4f & | operator*= (double) |
Multiplies the matrix by a float. More... | |
GF_API GfMatrix4f & | operator+= (const GfMatrix4f &m) |
Adds matrix m to this matrix. More... | |
GF_API GfMatrix4f & | operator-= (const GfMatrix4f &m) |
Subtracts matrix m from this matrix. More... | |
GF_API GfMatrix4f & | SetScale (float scaleFactor) |
Sets matrix to specify a uniform scaling by scaleFactor. More... | |
GF_API GfMatrix4f | RemoveScaleShear () const |
3D Transformation Utilities | |
GF_API GfMatrix4f & | SetRotate (const GfQuatf &rot) |
GF_API GfMatrix4f & | SetRotateOnly (const GfQuatf &rot) |
GF_API GfMatrix4f & | SetRotate (const GfRotation &rot) |
GF_API GfMatrix4f & | SetRotateOnly (const GfRotation &rot) |
GF_API GfMatrix4f & | SetRotate (const GfMatrix3f &mx) |
GF_API GfMatrix4f & | SetRotateOnly (const GfMatrix3f &mx) |
GF_API GfMatrix4f & | SetScale (const GfVec3f &scaleFactors) |
GF_API GfMatrix4f & | SetTranslate (const GfVec3f &trans) |
GF_API GfMatrix4f & | SetTranslateOnly (const GfVec3f &t) |
GF_API GfMatrix4f & | SetTransform (const GfRotation &rotate, const GfVec3f &translate) |
GF_API GfMatrix4f & | SetTransform (const GfMatrix3f &rotmx, const GfVec3f &translate) |
GF_API GfMatrix4f & | SetLookAt (const GfVec3f &eyePoint, const GfVec3f ¢erPoint, const GfVec3f &upDirection) |
GF_API GfMatrix4f & | SetLookAt (const GfVec3f &eyePoint, const GfRotation &orientation) |
GF_API bool | Factor (GfMatrix4f *r, GfVec3f *s, GfMatrix4f *u, GfVec3f *t, GfMatrix4f *p, float eps=1e-5) const |
GfVec3f | ExtractTranslation () const |
GF_API GfRotation | ExtractRotation () const |
GF_API GfQuatf | ExtractRotationQuat () const |
GF_API GfVec3f | DecomposeRotation (const GfVec3f &axis0, const GfVec3f &axis1, const GfVec3f &axis2) const |
GF_API GfMatrix3f | ExtractRotationMatrix () const |
GfVec3d | Transform (const GfVec3d &vec) const |
GfVec3f | Transform (const GfVec3f &vec) const |
GfVec3d | TransformDir (const GfVec3d &vec) const |
GfVec3f | TransformDir (const GfVec3f &vec) const |
GfVec3d | TransformAffine (const GfVec3d &vec) const |
GfVec3f | TransformAffine (const GfVec3f &vec) const |
Static Public Attributes | |
static const size_t | numRows = 4 |
static const size_t | numColumns = 4 |
Friends | |
class | GfMatrix4d |
size_t | hash_value (GfMatrix4f const &m) |
Hash. More... | |
GfMatrix4f | operator* (const GfMatrix4f &m1, double d) |
Returns the product of a matrix and a float. More... | |
GfMatrix4f | operator* (double d, const GfMatrix4f &m) |
GF_API friend GfMatrix4f | operator- (const GfMatrix4f &m) |
Returns the unary negation of matrix m. More... | |
GfMatrix4f | operator+ (const GfMatrix4f &m1, const GfMatrix4f &m2) |
Adds matrix m2 to m1. More... | |
GfMatrix4f | operator- (const GfMatrix4f &m1, const GfMatrix4f &m2) |
Subtracts matrix m2 from m1. More... | |
GfMatrix4f | operator* (const GfMatrix4f &m1, const GfMatrix4f &m2) |
Multiplies matrix m1 by m2. More... | |
GfMatrix4f | operator/ (const GfMatrix4f &m1, const GfMatrix4f &m2) |
Divides matrix m1 by m2 (that is, m1 * inv(m2) ). More... | |
GfVec4f | operator* (const GfMatrix4f &m, const GfVec4f &vec) |
Returns the product of a matrix m and a column vector vec. More... | |
GfVec4f | operator* (const GfVec4f &vec, const GfMatrix4f &m) |
Returns the product of row vector vec and a matrix m. More... | |
Stores a 4x4 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.
The following methods interpret a GfMatrix4f as a 3D transformation: SetRotate(), SetScale(), SetTranslate(), SetLookAt(), Factor(), ExtractTranslation(), ExtractRotation(), Transform(), TransformDir(). By convention, vectors are treated primarily as row vectors, implying the following:
Definition at line 87 of file matrix4f.h.
typedef float GfMatrix4f::ScalarType |
Definition at line 90 of file matrix4f.h.
|
default |
Default constructor. Leaves the matrix component values undefined.
|
inline |
Constructor. Initializes the matrix from 16 independent float
values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.
Definition at line 101 of file matrix4f.h.
|
inline |
Constructor. Initializes the matrix from a 4x4 array of float
values, specified in row-major order.
Definition at line 113 of file matrix4f.h.
|
inlineexplicit |
Constructor. Explicitly initializes the matrix to s times the identity matrix.
Definition at line 119 of file matrix4f.h.
|
inlineexplicit |
Constructor. Explicitly initializes the matrix to diagonal form, with the i th element on the diagonal set to v[i]
.
Definition at line 125 of file matrix4f.h.
|
explicit |
Constructor. Initialize the matrix from a vector of vectors of double. The vector is expected to be 4x4. If it is too big, only the first 4 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.
Constructor. Initialize the matrix from a vector of vectors of float. The vector is expected to be 4x4. If it is too big, only the first 4 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.
|
explicit |
Constructor. Initialize the matrix from 4 row vectors of double. Each vector is expected to length 4. If it is too big, only the first 4 items will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.
|
explicit |
Constructor. Initialize the matrix from 4 row vectors of float. Each vector is expected to length 4. If it is too big, only the first 4 items will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.
GF_API GfMatrix4f::GfMatrix4f | ( | const GfRotation & | rotate, |
const GfVec3f & | translate | ||
) |
Constructor. Initializes a transformation matrix to perform the indicated rotation and translation.
GF_API GfMatrix4f::GfMatrix4f | ( | const GfMatrix3f & | rotmx, |
const GfVec3f & | translate | ||
) |
Constructor. Initializes a transformation matrix to perform the indicated rotation and translation.
|
explicit |
This explicit constructor converts a "double" matrix to a "float" matrix.
|
inline |
Returns raw access to components of matrix as an array of float
values. Components are in row-major order.
Definition at line 273 of file matrix4f.h.
|
inline |
Returns const raw access to components of matrix as an array of float
values. Components are in row-major order.
Definition at line 279 of file matrix4f.h.
GF_API GfVec3f GfMatrix4f::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 GfMatrix4f::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 GfMatrix3f GfMatrix4f::ExtractRotationMatrix | ( | ) | 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.
Return the rotation corresponding to this matrix as a quaternion. This works well only if the matrix represents a rotation.
For good results, consider calling Orthonormalize() before calling this method.
|
inline |
Returns the translation part of the matrix, defined as the first three elements of the last row.
Definition at line 618 of file matrix4f.h.
GF_API bool GfMatrix4f::Factor | ( | GfMatrix4f * | r, |
GfVec3f * | s, | ||
GfMatrix4f * | u, | ||
GfVec3f * | t, | ||
GfMatrix4f * | p, | ||
float | eps = 1e-5 |
||
) | const |
Factors the matrix into 5 components:
M = r * s * -r * u * t
where Returns false
if the matrix is singular (as determined by eps). In that case, any zero scales in s are clamped to eps to allow computation of u.
Fills a 4x4 array of float
values with the values in the matrix, specified in row-major order.
|
inline |
Returns vector components as an array of float
values.
Definition at line 284 of file matrix4f.h.
|
inline |
Returns vector components as a const array of float
values.
Definition at line 289 of file matrix4f.h.
Gets a column of the matrix as a Vec4.
Definition at line 208 of file matrix4f.h.
GF_API double GfMatrix4f::GetDeterminant | ( | ) | const |
Returns the determinant of the matrix.
|
inline |
Returns the determinant of the upper 3x3 matrix. This method is useful when the matrix describes a linear transformation such as a rotation or scale because the other values in the 4x4 matrix are not important.
Definition at line 379 of file matrix4f.h.
GF_API double GfMatrix4f::GetHandedness | ( | ) | const |
Returns the sign of the determinant of the upper 3x3 matrix, i.e. 1 for a right-handed matrix, -1 for a left-handed matrix, and 0 for a singular matrix.
GF_API GfMatrix4f GfMatrix4f::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 GfMatrix4f GfMatrix4f::GetOrthonormalized | ( | bool | issueWarning = true | ) | const |
Returns an orthonormalized copy of the matrix.
Gets a row of the matrix as a Vec4.
Definition at line 203 of file matrix4f.h.
Gets a row of the matrix as a Vec3.
Definition at line 372 of file matrix4f.h.
GF_API GfMatrix4f GfMatrix4f::GetTranspose | ( | ) | const |
Returns the transpose of the matrix.
|
inline |
Returns true, if the row vectors of the upper 3x3 matrix form an orthogonal basis. Note they do not have to be unit length for this test to return true.
Definition at line 386 of file matrix4f.h.
|
inline |
Returns true if the vectors in the upper 3x3 matrix form a left-handed coordinate system.
Definition at line 424 of file matrix4f.h.
|
inline |
Returns true if the vectors in the upper 3x3 matrix form a right-handed coordinate system.
Definition at line 418 of file matrix4f.h.
|
inline |
Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.
Definition at line 337 of file matrix4f.h.
|
inline |
Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.
Definition at line 343 of file matrix4f.h.
GF_API GfMatrix4f& GfMatrix4f::operator*= | ( | const GfMatrix4f & | m | ) |
Post-multiplies matrix m into this matrix.
GF_API GfMatrix4f& GfMatrix4f::operator*= | ( | double | ) |
Multiplies the matrix by a float.
GF_API GfMatrix4f& GfMatrix4f::operator+= | ( | const GfMatrix4f & | m | ) |
Adds matrix m to this matrix.
GF_API GfMatrix4f& GfMatrix4f::operator-= | ( | const GfMatrix4f & | m | ) |
Subtracts matrix m from this matrix.
GF_API bool GfMatrix4f::operator== | ( | const GfMatrix4d & | m | ) | const |
Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.
GF_API bool GfMatrix4f::operator== | ( | const GfMatrix4f & | m | ) | const |
Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.
Accesses an indexed row i of the matrix as an array of 4 float
values so that standard indexing (such as m[0][1]
) works correctly.
Definition at line 296 of file matrix4f.h.
Accesses an indexed row i of the matrix as an array of 4 float
values so that standard indexing (such as m[0][1]
) works correctly.
Definition at line 301 of file matrix4f.h.
GF_API bool GfMatrix4f::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.
GF_API GfMatrix4f GfMatrix4f::RemoveScaleShear | ( | ) | const |
Returns the matrix with any scaling or shearing removed, leaving only the rotation and translation. If the matrix cannot be decomposed, returns the original matrix.
|
inline |
Sets the matrix from 16 independent float
values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.
Definition at line 215 of file matrix4f.h.
|
inline |
Sets the matrix from a 4x4 array of float
values, specified in row-major order.
Definition at line 228 of file matrix4f.h.
Sets a column of the matrix from a Vec4.
Definition at line 195 of file matrix4f.h.
GF_API GfMatrix4f& GfMatrix4f::SetDiagonal | ( | float | s | ) |
Sets the matrix to s times the identity matrix.
GF_API GfMatrix4f& GfMatrix4f::SetDiagonal | ( | const GfVec4f & | ) |
Sets the matrix to have diagonal (v[0], v[1], v[2], v[3]
).
|
inline |
Sets the matrix to the identity matrix.
Definition at line 249 of file matrix4f.h.
GF_API GfMatrix4f& GfMatrix4f::SetLookAt | ( | const GfVec3f & | eyePoint, |
const GfVec3f & | centerPoint, | ||
const GfVec3f & | upDirection | ||
) |
Sets the matrix to specify a viewing matrix from parameters similar to those used by gluLookAt(3G)
. eyePoint represents the eye point in world space. centerPoint represents the world-space center of attention. upDirection is a vector indicating which way is up.
GF_API GfMatrix4f& GfMatrix4f::SetLookAt | ( | const GfVec3f & | eyePoint, |
const GfRotation & | orientation | ||
) |
Sets the matrix to specify a viewing matrix from a world-space eyePoint and a world-space rotation that rigidly rotates the orientation from its canonical frame, which is defined to be looking along the -z
axis with the +y
axis as the up direction.
GF_API GfMatrix4f& GfMatrix4f::SetRotate | ( | const GfQuatf & | rot | ) |
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
GF_API GfMatrix4f& GfMatrix4f::SetRotate | ( | const GfRotation & | rot | ) |
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
GF_API GfMatrix4f& GfMatrix4f::SetRotate | ( | const GfMatrix3f & | mx | ) |
Sets the matrix to specify a rotation equivalent to mx, and clears the translation.
GF_API GfMatrix4f& GfMatrix4f::SetRotateOnly | ( | const GfQuatf & | rot | ) |
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
GF_API GfMatrix4f& GfMatrix4f::SetRotateOnly | ( | const GfRotation & | rot | ) |
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
GF_API GfMatrix4f& GfMatrix4f::SetRotateOnly | ( | const GfMatrix3f & | mx | ) |
Sets the matrix to specify a rotation equivalent to mx, without clearing the translation.
Sets a row of the matrix from a Vec4.
Definition at line 187 of file matrix4f.h.
Sets a row of the matrix from a Vec3. The fourth element of the row is ignored.
Definition at line 365 of file matrix4f.h.
GF_API GfMatrix4f& GfMatrix4f::SetScale | ( | float | scaleFactor | ) |
Sets matrix to specify a uniform scaling by scaleFactor.
GF_API GfMatrix4f& GfMatrix4f::SetScale | ( | const GfVec3f & | scaleFactors | ) |
Sets the matrix to specify a nonuniform scaling in x, y, and z by the factors in vector scaleFactors.
GF_API GfMatrix4f& GfMatrix4f::SetTransform | ( | const GfRotation & | rotate, |
const GfVec3f & | translate | ||
) |
Sets matrix to specify a rotation by rotate and a translation by translate.
GF_API GfMatrix4f& GfMatrix4f::SetTransform | ( | const GfMatrix3f & | rotmx, |
const GfVec3f & | translate | ||
) |
Sets matrix to specify a rotation by rotmx and a translation by translate.
GF_API GfMatrix4f& GfMatrix4f::SetTranslate | ( | const GfVec3f & | trans | ) |
Sets matrix to specify a translation by the vector trans, and clears the rotation.
GF_API GfMatrix4f& GfMatrix4f::SetTranslateOnly | ( | const GfVec3f & | t | ) |
Sets matrix to specify a translation by the vector trans, without clearing the rotation.
|
inline |
Sets the matrix to zero.
Definition at line 254 of file matrix4f.h.
Transforms the row vector vec by the matrix, returning the result. This treats the vector as a 4-component vector whose fourth component is 1.
Definition at line 659 of file matrix4f.h.
Transforms the row vector vec by the matrix, returning the result. This treats the vector as a 4-component vector whose fourth component is 1. This is an overloaded method; it differs from the other version in that it returns a different value type.
Definition at line 671 of file matrix4f.h.
Transforms the row vector vec by the matrix, returning the result. This treats the vector as a 4-component vector whose fourth component is 1 and ignores the fourth column of the matrix (i.e. assumes it is (0, 0, 0, 1)).
Definition at line 707 of file matrix4f.h.
Transforms the row vector vec by the matrix, returning the result. This treats the vector as a 4-component vector whose fourth component is 1 and ignores the fourth column of the matrix (i.e. assumes it is (0, 0, 0, 1)).
Definition at line 718 of file matrix4f.h.
Transforms row vector vec by the matrix, returning the result. This treats the vector as a direction vector, so the translation information in the matrix is ignored. That is, it treats the vector as a 4-component vector whose fourth component is 0.
Definition at line 683 of file matrix4f.h.
Transforms row vector vec by the matrix, returning the result. This treats the vector as a direction vector, so the translation information in the matrix is ignored. That is, it treats the vector as a 4-component vector whose fourth component is 0. This is an overloaded method; it differs from the other version in that it returns a different value type.
Definition at line 696 of file matrix4f.h.
|
friend |
Definition at line 746 of file matrix4f.h.
|
friend |
Hash.
Definition at line 304 of file matrix4f.h.
|
friend |
Returns the product of a matrix and a float.
Definition at line 437 of file matrix4f.h.
|
friend |
Definition at line 445 of file matrix4f.h.
|
friend |
Multiplies matrix m1 by m2.
Definition at line 479 of file matrix4f.h.
|
friend |
Returns the product of a matrix m and a column vector vec.
Definition at line 493 of file matrix4f.h.
|
friend |
Returns the product of row vector vec and a matrix m.
Definition at line 501 of file matrix4f.h.
|
friend |
Adds matrix m2 to m1.
Definition at line 463 of file matrix4f.h.
|
friend |
Returns the unary negation of matrix m.
|
friend |
Subtracts matrix m2 from m1.
Definition at line 471 of file matrix4f.h.
|
friend |
Divides matrix m1 by m2 (that is, m1 * inv(m2)
).
Definition at line 487 of file matrix4f.h.
|
static |
Definition at line 93 of file matrix4f.h.
|
static |
Definition at line 92 of file matrix4f.h.