28 #ifndef PXR_BASE_GF_MATRIX2D_H 29 #define PXR_BASE_GF_MATRIX2D_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
65 typedef double ScalarType;
67 static const size_t numRows = 2;
68 static const size_t numColumns = 2;
77 double m10,
double m11) {
113 explicit GfMatrix2d(
const std::vector< std::vector<double> >& v);
122 explicit GfMatrix2d(
const std::vector< std::vector<float> >& v);
142 return GfVec2d(_mtx[i][0], _mtx[i][1]);
147 return GfVec2d(_mtx[0][i], _mtx[1][i]);
154 double m10,
double m11) {
155 _mtx[0][0] = m00; _mtx[0][1] = m01;
156 _mtx[1][0] = m10; _mtx[1][1] = m11;
163 _mtx[0][0] = m[0][0];
164 _mtx[0][1] = m[0][1];
165 _mtx[1][0] = m[1][0];
166 _mtx[1][1] = m[1][1];
191 double*
Get(
double m[2][2])
const;
231 boost::hash_combine(h, *p++);
248 return !(*
this == m);
254 return !(*
this == m);
340 return GfVec2d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1],
341 vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1]);
346 return GfVec2d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0],
347 vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1]);
380 PXR_NAMESPACE_CLOSE_SCOPE
382 #endif // PXR_BASE_GF_MATRIX2D_H GF_API GfMatrix2d & SetDiagonal(double s)
Sets the matrix to s times the identity matrix.
GfMatrix2d & SetIdentity()
Sets the matrix to the identity matrix.
void SetColumn(int i, const GfVec2d &v)
Sets a column of the matrix from a Vec2.
GfMatrix2d & Set(double m00, double m01, double m10, double m11)
Sets the matrix from 4 independent double values, specified in row-major order.
GF_API bool operator==(const GfMatrix2d &m) const
Tests for element-wise matrix equality.
double * data()
Returns raw access to components of matrix as an array of double values.
GfMatrix2d(double s)
Constructor.
GF_API GfMatrix2d & operator -=(const GfMatrix2d &m)
Subtracts matrix m from this matrix.
GF_API std::ostream & operator<<(std::ostream &, GfMatrix2d const &)
Output a GfMatrix2d.
GfMatrix2d()=default
Default constructor. Leaves the matrix component values undefined.
GfVec2d GetRow(int i) const
Gets a row of the matrix as a Vec2.
friend size_t hash_value(GfMatrix2d const &m)
Hash.
Basic type for a vector of 2 double components.
GF_API GfMatrix2d GetInverse(double *det=NULL, double eps=0) const
Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular.
GfMatrix2d(int s)
This explicit constructor initializes the matrix to s times the identity matrix.
Stores a 2x2 matrix of double elements.
friend GfVec2d operator *(const GfMatrix2d &m, const GfVec2d &vec)
Returns the product of a matrix m and a column vector vec.
GF_API double GetDeterminant() const
Returns the determinant of the matrix.
friend GfMatrix2d operator *(const GfMatrix2d &m1, double d)
Returns the product of a matrix and a double.
GF_API GfMatrix2d GetTranspose() const
Returns the transpose of the matrix.
GfMatrix2d(double m00, double m01, double m10, double m11)
Constructor.
void SetRow(int i, const GfVec2d &v)
Sets a row of the matrix from a Vec2.
T * GetData()
Return a pointer to the start of all the data.
friend GfMatrix2d operator *(const GfMatrix2d &m1, const GfMatrix2d &m2)
Multiplies matrix m1 by m2.
A metafunction with a static const bool member 'value' that is true for GfMatrix types,...
GF_API GfMatrix2d & operator *=(const GfMatrix2d &m)
Post-multiplies matrix m into this matrix.
bool operator !=(const GfMatrix2d &m) const
Tests for element-wise matrix inequality.
bool operator !=(const GfMatrix2f &m) const
Tests for element-wise matrix inequality.
GF_API double * Get(double m[2][2]) const
Fills a 2x2 array of double values with the values in the matrix, specified in row-major order.
friend GfVec2d operator *(const GfVec2d &vec, const GfMatrix2d &m)
Returns the product of row vector vec and a matrix m.
GfMatrix2d & Set(const double m[2][2])
Sets the matrix from a 2x2 array of double values, specified in row-major order.
GF_API GfMatrix2d & operator+=(const GfMatrix2d &m)
Adds matrix m to this matrix.
GfMatrix2d(const GfVec2d &v)
Constructor.
const double * operator [](int i) const
Accesses an indexed row i of the matrix as an array of 2 double values so that standard indexing (suc...
double * GetArray()
Returns vector components as an array of double values.
Basic type for a vector of 2 float components.
friend GfMatrix2d operator/(const GfMatrix2d &m1, const GfMatrix2d &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
double * operator [](int i)
Accesses an indexed row i of the matrix as an array of 2 double values so that standard indexing (suc...
friend GfMatrix2d operator+(const GfMatrix2d &m1, const GfMatrix2d &m2)
Adds matrix m2 to m1.
GfMatrix2d(const double m[2][2])
Constructor.
GF_API friend GfMatrix2d operator -(const GfMatrix2d &m)
Returns the unary negation of matrix m.
friend GfMatrix2d operator -(const GfMatrix2d &m1, const GfMatrix2d &m2)
Subtracts matrix m2 from m1.
GfMatrix2d & SetZero()
Sets the matrix to zero.
const double * GetArray() const
Returns vector components as a const array of double values.
GF_API bool GfIsClose(GfMatrix2d const &m1, GfMatrix2d const &m2, double tolerance)
Tests for equality within a given tolerance, returning true if the difference between each component ...
Stores a 2x2 matrix of float elements.
const double * data() const
Returns const raw access to components of matrix as an array of double values.
GfVec2d GetColumn(int i) const
Gets a column of the matrix as a Vec2.