28 #ifndef PXR_BASE_GF_MATRIX3F_H 29 #define PXR_BASE_GF_MATRIX3F_H 35 #include "pxr/base/gf/api.h" 37 #include "pxr/base/gf/matrixData.h" 39 #include "pxr/base/gf/traits.h" 41 #include <boost/functional/hash.hpp> 46 PXR_NAMESPACE_OPEN_SCOPE
85 typedef float ScalarType;
87 static const size_t numRows = 3;
88 static const size_t numColumns = 3;
97 float m10,
float m11,
float m12,
98 float m20,
float m21,
float m22) {
135 explicit GfMatrix3f(
const std::vector< std::vector<double> >& v);
144 explicit GfMatrix3f(
const std::vector< std::vector<float> >& v);
174 return GfVec3f(_mtx[i][0], _mtx[i][1], _mtx[i][2]);
179 return GfVec3f(_mtx[0][i], _mtx[1][i], _mtx[2][i]);
186 float m10,
float m11,
float m12,
187 float m20,
float m21,
float m22) {
188 _mtx[0][0] = m00; _mtx[0][1] = m01; _mtx[0][2] = m02;
189 _mtx[1][0] = m10; _mtx[1][1] = m11; _mtx[1][2] = m12;
190 _mtx[2][0] = m20; _mtx[2][1] = m21; _mtx[2][2] = m22;
197 _mtx[0][0] = m[0][0];
198 _mtx[0][1] = m[0][1];
199 _mtx[0][2] = m[0][2];
200 _mtx[1][0] = m[1][0];
201 _mtx[1][1] = m[1][1];
202 _mtx[1][2] = m[1][2];
203 _mtx[2][0] = m[2][0];
204 _mtx[2][1] = m[2][1];
205 _mtx[2][2] = m[2][2];
230 float*
Get(
float m[3][3])
const;
270 boost::hash_combine(h, *p++);
287 return !(*
this == m);
293 return !(*
this == m);
411 return GfVec3f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1] + vec[2] * m._mtx[0][2],
412 vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[1][2],
413 vec[0] * m._mtx[2][0] + vec[1] * m._mtx[2][1] + vec[2] * m._mtx[2][2]);
418 return GfVec3f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0] + vec[2] * m._mtx[2][0],
419 vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[2][1],
420 vec[0] * m._mtx[0][2] + vec[1] * m._mtx[1][2] + vec[2] * m._mtx[2][2]);
475 void _SetRotateFromQuat(
float r,
const GfVec3f& i);
497 PXR_NAMESPACE_CLOSE_SCOPE
499 #endif // PXR_BASE_GF_MATRIX3F_H GF_API GfMatrix3f GetInverse(double *det=NULL, double eps=0) const
Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular.
friend GfMatrix3f operator/(const GfMatrix3f &m1, const GfMatrix3f &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
GfMatrix3f(float s)
Constructor.
float * GetArray()
Returns vector components as an array of float values.
const float * data() const
Returns const raw access to components of matrix as an array of float values.
GfMatrix3f(const GfVec3f &v)
Constructor.
GF_API GfMatrix3f & SetRotate(const GfQuatf &rot)
Sets the matrix to specify a rotation equivalent to rot.
friend GfVec3f operator *(const GfMatrix3f &m, const GfVec3f &vec)
Returns the product of a matrix m and a column vector vec.
GF_API bool Orthonormalize(bool issueWarning=true)
Makes the matrix orthonormal in place.
GF_API float * Get(float m[3][3]) const
Fills a 3x3 array of float values with the values in the matrix, specified in row-major order.
Basic type for a vector of 3 float components.
GF_API GfMatrix3f GetTranspose() const
Returns the transpose of the matrix.
Basic type: complex number with scalar real part and vector imaginary part.
GfVec3f GetColumn(int i) const
Gets a column of the matrix as a Vec3.
bool operator !=(const GfMatrix3d &m) const
Tests for element-wise matrix inequality.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
GfMatrix3f & Set(const float m[3][3])
Sets the matrix from a 3x3 array of float values, specified in row-major order.
void SetRow(int i, const GfVec3f &v)
Sets a row of the matrix from a Vec3.
Stores a 3x3 matrix of float elements.
GfMatrix3f(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
Constructor.
GF_API GfMatrix3f & operator+=(const GfMatrix3f &m)
Adds matrix m to this matrix.
const float * operator [](int i) const
Accesses an indexed row i of the matrix as an array of 3 float values so that standard indexing (such...
T * GetData()
Return a pointer to the start of all the data.
A metafunction with a static const bool member 'value' that is true for GfMatrix types,...
void SetColumn(int i, const GfVec3f &v)
Sets a column of the matrix from a Vec3.
float * operator [](int i)
Accesses an indexed row i of the matrix as an array of 3 float values so that standard indexing (such...
const float * GetArray() const
Returns vector components as a const array of float values.
GF_API std::ostream & operator<<(std::ostream &, GfMatrix3f const &)
Output a GfMatrix3f.
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.
GfMatrix3f(const float m[3][3])
Constructor.
bool IsLeftHanded() const
Returns true if the vectors in matrix form a left-handed coordinate system.
GF_API GfMatrix3f GetOrthonormalized(bool issueWarning=true) const
Returns an orthonormalized copy of the matrix.
GF_API friend GfMatrix3f operator -(const GfMatrix3f &m)
Returns the unary negation of matrix m.
friend GfVec3f operator *(const GfVec3f &vec, const GfMatrix3f &m)
Returns the product of row vector vec and a matrix m.
friend GfMatrix3f operator *(const GfMatrix3f &m1, double d)
Returns the product of a matrix and a float.
GF_API bool operator==(const GfMatrix3d &m) const
Tests for element-wise matrix equality.
friend GfMatrix3f operator -(const GfMatrix3f &m1, const GfMatrix3f &m2)
Subtracts matrix m2 from m1.
GfMatrix3f()=default
Default constructor. Leaves the matrix component values undefined.
friend GfMatrix3f operator *(const GfMatrix3f &m1, const GfMatrix3f &m2)
Multiplies matrix m1 by m2.
GF_API bool GfIsClose(GfMatrix3f const &m1, GfMatrix3f const &m2, double tolerance)
Tests for equality within a given tolerance, returning true if the difference between each component ...
GfMatrix3f & Set(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
Sets the matrix from 9 independent float values, specified in row-major order.
float * data()
Returns raw access to components of matrix as an array of float values.
GfMatrix3f & SetIdentity()
Sets the matrix to the identity matrix.
GF_API GfMatrix3f & operator *=(const GfMatrix3f &m)
Post-multiplies matrix m into this matrix.
GfMatrix3f(int s)
This explicit constructor initializes the matrix to s times the identity matrix.
GfVec3f GetRow(int i) const
Gets a row of the matrix as a Vec3.
Stores a 3x3 matrix of double elements.
bool operator !=(const GfMatrix3f &m) const
Tests for element-wise matrix inequality.
GF_API GfMatrix3f & SetDiagonal(float s)
Sets the matrix to s times the identity matrix.
bool IsRightHanded() const
Returns true if the vectors in the matrix form a right-handed coordinate system.
friend size_t hash_value(GfMatrix3f const &m)
Hash.
GF_API GfMatrix3f & SetScale(float scaleFactor)
Sets matrix to specify a uniform scaling by scaleFactor.
Basic type: 3-space rotation specification.
GF_API GfMatrix3f & operator -=(const GfMatrix3f &m)
Subtracts matrix m from this matrix.
GF_API GfVec3f DecomposeRotation(const GfVec3f &axis0, const GfVec3f &axis1, const GfVec3f &axis2) const
Decompose the rotation corresponding to this matrix about 3 orthogonal axes.
GF_API GfRotation ExtractRotation() const
Returns the rotation corresponding to this matrix.
GfMatrix3f & SetZero()
Sets the matrix to zero.
GF_API GfQuaternion ExtractRotationQuaternion() const
Returns the quaternion corresponding to this matrix.
friend GfMatrix3f operator+(const GfMatrix3f &m1, const GfMatrix3f &m2)
Adds matrix m2 to m1.