28 #ifndef PXR_BASE_GF_MATRIX2F_H 29 #define PXR_BASE_GF_MATRIX2F_H 35 #include "pxr/base/gf/api.h" 37 #include "pxr/base/gf/matrixData.h" 39 #include "pxr/base/gf/traits.h" 45 PXR_NAMESPACE_OPEN_SCOPE
64 typedef float ScalarType;
66 static const size_t numRows = 2;
67 static const size_t numColumns = 2;
76 float m10,
float m11) {
112 explicit GfMatrix2f(
const std::vector< std::vector<double> >& v);
121 explicit GfMatrix2f(
const std::vector< std::vector<float> >& v);
141 return GfVec2f(_mtx[i][0], _mtx[i][1]);
146 return GfVec2f(_mtx[0][i], _mtx[1][i]);
153 float m10,
float m11) {
154 _mtx[0][0] = m00; _mtx[0][1] = m01;
155 _mtx[1][0] = m10; _mtx[1][1] = m11;
162 _mtx[0][0] = m[0][0];
163 _mtx[0][1] = m[0][1];
164 _mtx[1][0] = m[1][0];
165 _mtx[1][1] = m[1][1];
190 float*
Get(
float m[2][2])
const;
247 return !(*
this == m);
253 return !(*
this == m);
339 return GfVec2f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1],
340 vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1]);
345 return GfVec2f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0],
346 vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1]);
369 PXR_NAMESPACE_CLOSE_SCOPE
371 #endif // PXR_BASE_GF_MATRIX2F_H GF_API float * Get(float m[2][2]) const
Fills a 2x2 array of float values with the values in the matrix, specified in row-major order.
GF_API bool GfIsClose(GfMatrix2f const &m1, GfMatrix2f const &m2, double tolerance)
Tests for equality within a given tolerance, returning true if the difference between each component ...
GfMatrix2f(const GfVec2f &v)
Constructor.
GfVec2f GetColumn(int i) const
Gets a column of the matrix as a Vec2.
GF_API GfMatrix2f & operator+=(const GfMatrix2f &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 2 float values so that standard indexing (such...
float * data()
Returns raw access to components of matrix as an array of float values.
GfMatrix2f & Set(float m00, float m01, float m10, float m11)
Sets the matrix from 4 independent float values, specified in row-major order.
float * operator [](int i)
Accesses an indexed row i of the matrix as an array of 2 float values so that standard indexing (such...
const float * GetArray() const
Returns vector components as a const array of float values.
GF_API double GetDeterminant() const
Returns the determinant of the matrix.
GF_API GfMatrix2f & SetDiagonal(float s)
Sets the matrix to s times the identity matrix.
GF_API GfMatrix2f & operator -=(const GfMatrix2f &m)
Subtracts matrix m from this matrix.
GF_API std::ostream & operator<<(std::ostream &, GfMatrix2f const &)
Output a GfMatrix2f.
void SetRow(int i, const GfVec2f &v)
Sets a row of the matrix from a Vec2.
GF_API bool operator==(const GfMatrix2d &m) const
Tests for element-wise matrix equality.
GfMatrix2f(int s)
This explicit constructor initializes the matrix to s times the identity matrix.
GfMatrix2f & Set(const float m[2][2])
Sets the matrix from a 2x2 array of float values, specified in row-major order.
Stores a 2x2 matrix of double elements.
GfMatrix2f(const float m[2][2])
Constructor.
bool operator !=(const GfMatrix2f &m) const
Tests for element-wise matrix inequality.
GfMatrix2f(float s)
Constructor.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GF_API GfMatrix2f & operator *=(const GfMatrix2f &m)
Post-multiplies matrix m into this matrix.
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,...
GF_API friend GfMatrix2f operator -(const GfMatrix2f &m)
Returns the unary negation of matrix m.
friend GfMatrix2f operator/(const GfMatrix2f &m1, const GfMatrix2f &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
GF_API GfMatrix2f GetTranspose() const
Returns the transpose of the matrix.
GfVec2f GetRow(int i) const
Gets a row of the matrix as a Vec2.
float * GetArray()
Returns vector components as an array of float values.
friend size_t hash_value(GfMatrix2f const &m)
Hash.
friend GfMatrix2f operator *(const GfMatrix2f &m1, double d)
Returns the product of a matrix and a float.
GfMatrix2f & SetZero()
Sets the matrix to zero.
friend GfVec2f operator *(const GfVec2f &vec, const GfMatrix2f &m)
Returns the product of row vector vec and a matrix m.
bool operator !=(const GfMatrix2d &m) const
Tests for element-wise matrix inequality.
friend GfMatrix2f operator *(const GfMatrix2f &m1, const GfMatrix2f &m2)
Multiplies matrix m1 by m2.
GfMatrix2f()=default
Default constructor. Leaves the matrix component values undefined.
Basic type for a vector of 2 float components.
const float * data() const
Returns const raw access to components of matrix as an array of float values.
friend GfMatrix2f operator+(const GfMatrix2f &m1, const GfMatrix2f &m2)
Adds matrix m2 to m1.
void SetColumn(int i, const GfVec2f &v)
Sets a column of the matrix from a Vec2.
friend GfMatrix2f operator -(const GfMatrix2f &m1, const GfMatrix2f &m2)
Subtracts matrix m2 from m1.
friend GfVec2f operator *(const GfMatrix2f &m, const GfVec2f &vec)
Returns the product of a matrix m and a column vector vec.
GfMatrix2f(float m00, float m01, float m10, float m11)
Constructor.
Stores a 2x2 matrix of float elements.
GF_API GfMatrix2f GetInverse(double *det=NULL, double eps=0) const
Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular.
GfMatrix2f & SetIdentity()
Sets the matrix to the identity matrix.