11#ifndef PXR_BASE_GF_MATRIX3D_H
12#define PXR_BASE_GF_MATRIX3D_H
18#include "pxr/base/gf/api.h"
20#include "pxr/base/gf/matrixData.h"
22#include "pxr/base/gf/traits.h"
28PXR_NAMESPACE_OPEN_SCOPE
67 typedef double ScalarType;
69 static const size_t numRows = 3;
70 static const size_t numColumns = 3;
79 double m10,
double m11,
double m12,
80 double m20,
double m21,
double m22) {
117 explicit GfMatrix3d(
const std::vector< std::vector<double> >& v);
126 explicit GfMatrix3d(
const std::vector< std::vector<float> >& v);
156 return GfVec3d(_mtx[i][0], _mtx[i][1], _mtx[i][2]);
161 return GfVec3d(_mtx[0][i], _mtx[1][i], _mtx[2][i]);
168 double m10,
double m11,
double m12,
169 double m20,
double m21,
double m22) {
170 _mtx[0][0] = m00; _mtx[0][1] = m01; _mtx[0][2] = m02;
171 _mtx[1][0] = m10; _mtx[1][1] = m11; _mtx[1][2] = m12;
172 _mtx[2][0] = m20; _mtx[2][1] = m21; _mtx[2][2] = m22;
179 _mtx[0][0] = m[0][0];
180 _mtx[0][1] = m[0][1];
181 _mtx[0][2] = m[0][2];
182 _mtx[1][0] = m[1][0];
183 _mtx[1][1] = m[1][1];
184 _mtx[1][2] = m[1][2];
185 _mtx[2][0] = m[2][0];
186 _mtx[2][1] = m[2][1];
187 _mtx[2][2] = m[2][2];
212 double*
Get(
double m[3][3])
const;
274 return !(*
this == m);
280 return !(*
this == m);
398 return GfVec3d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1] + vec[2] * m._mtx[0][2],
399 vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[1][2],
400 vec[0] * m._mtx[2][0] + vec[1] * m._mtx[2][1] + vec[2] * m._mtx[2][2]);
405 return GfVec3d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0] + vec[2] * m._mtx[2][0],
406 vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[2][1],
407 vec[0] * m._mtx[0][2] + vec[1] * m._mtx[1][2] + vec[2] * m._mtx[2][2]);
462 void _SetRotateFromQuat(
double r,
const GfVec3d& i);
484PXR_NAMESPACE_CLOSE_SCOPE
Stores a 3x3 matrix of double elements.
GF_API GfMatrix3d GetTranspose() const
Returns the transpose of the matrix.
friend GfMatrix3d operator+(const GfMatrix3d &m1, const GfMatrix3d &m2)
Adds matrix m2 to m1.
friend GfMatrix3d operator*(const GfMatrix3d &m1, double d)
Returns the product of a matrix and a double.
GF_API GfMatrix3d(const GfRotation &rot)
Constructor. Initialize matrix from rotation.
GF_API GfMatrix3d & SetDiagonal(const GfVec3d &)
Sets the matrix to have diagonal (v[0], v[1], v[2]).
const double * data() const
Returns const raw access to components of matrix as an array of double values.
GF_API GfMatrix3d & SetScale(double scaleFactor)
Sets matrix to specify a uniform scaling by scaleFactor.
GF_API GfMatrix3d & SetRotate(const GfQuatd &rot)
Sets the matrix to specify a rotation equivalent to rot.
GF_API GfQuaternion ExtractRotationQuaternion() const
Returns the quaternion corresponding to this matrix.
GfVec3d GetRow(int i) const
Gets a row of the matrix as a Vec3.
GF_API friend GfMatrix3d operator-(const GfMatrix3d &m)
Returns the unary negation of matrix m.
GF_API GfMatrix3d(const std::vector< std::vector< double > > &v)
Constructor.
GF_API double GetDeterminant() const
Returns the determinant of the matrix.
GF_API GfMatrix3d & operator+=(const GfMatrix3d &m)
Adds matrix m to this matrix.
GfVec3d GetColumn(int i) const
Gets a column of the matrix as a Vec3.
double * operator[](int i)
Accesses an indexed row i of the matrix as an array of 3 double values so that standard indexing (suc...
friend GfMatrix3d operator/(const GfMatrix3d &m1, const GfMatrix3d &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
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.
GF_API bool operator==(const GfMatrix3d &m) const
Tests for element-wise matrix equality.
GfMatrix3d(double m00, double m01, double m02, double m10, double m11, double m12, double m20, double m21, double m22)
Constructor.
void SetRow(int i, const GfVec3d &v)
Sets a row of the matrix from a Vec3.
GfMatrix3d & SetZero()
Sets the matrix to zero.
GF_API double GetHandedness() const
Returns the sign of the determinant of the matrix, i.e.
GfMatrix3d & SetIdentity()
Sets the matrix to the identity matrix.
GF_API GfMatrix3d(const class GfMatrix3f &m)
This explicit constructor converts a "float" matrix to a "double" matrix.
GF_API GfMatrix3d & operator*=(const GfMatrix3d &m)
Post-multiplies matrix m into this matrix.
friend size_t hash_value(GfMatrix3d const &m)
Hash.
double * GetArray()
Returns vector components as an array of double values.
double * data()
Returns raw access to components of matrix as an array of double values.
GfMatrix3d(int s)
This explicit constructor initializes the matrix to s times the identity matrix.
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.
GfMatrix3d(const GfVec3d &v)
Constructor.
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.
GfMatrix3d(double s)
Constructor.
GfMatrix3d(const double m[3][3])
Constructor.
GfMatrix3d & Set(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.
GfMatrix3d & Set(const double m[3][3])
Sets the matrix from a 3x3 array of double values, specified in row-major order.
bool operator!=(const GfMatrix3d &m) const
Tests for element-wise matrix inequality.
GF_API bool Orthonormalize(bool issueWarning=true)
Makes the matrix orthonormal in place.
GF_API GfMatrix3d & SetDiagonal(double s)
Sets the matrix to s times the identity matrix.
bool IsLeftHanded() const
Returns true if the vectors in matrix form a left-handed coordinate system.
GF_API GfMatrix3d(const GfQuatd &rot)
Constructor. Initialize matrix from a quaternion.
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.
bool IsRightHanded() const
Returns true if the vectors in the matrix form a right-handed coordinate system.
void SetColumn(int i, const GfVec3d &v)
Sets a column of the matrix from a Vec3.
GfMatrix3d()=default
Default constructor. Leaves the matrix component values undefined.
GF_API GfMatrix3d(const std::vector< std::vector< float > > &v)
Constructor.
GF_API GfMatrix3d & operator-=(const GfMatrix3d &m)
Subtracts matrix m from this matrix.
GF_API GfRotation ExtractRotation() const
Returns the rotation corresponding to this matrix.
const double * GetArray() const
Returns vector components as a const array of double values.
GF_API GfMatrix3d GetOrthonormalized(bool issueWarning=true) const
Returns an orthonormalized copy of the matrix.
GF_API GfMatrix3d & SetRotate(const GfRotation &rot)
Sets the matrix to specify a rotation equivalent to rot.
Stores a 3x3 matrix of float elements.
A class template used by GfMatrixXX to store values.
T * GetData()
Return a pointer to the start of all the data.
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Basic type: complex number with scalar real part and vector imaginary part.
Basic type: 3-space rotation specification.
Basic type for a vector of 3 double components.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
GF_API bool GfIsClose(GfMatrix3d const &m1, GfMatrix3d const &m2, double tolerance)
Tests for equality within a given tolerance, returning true if the difference between each component ...
A metafunction with a static const bool member 'value' that is true for GfMatrix types,...