All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
matrix4d.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
25 // This file is generated by a script. Do not edit directly. Edit the
26 // matrix4.template.h file to make changes.
27 
28 #ifndef GF_MATRIX4D_H
29 #define GF_MATRIX4D_H
30 
33 
34 #include "pxr/pxr.h"
35 #include "pxr/base/gf/api.h"
36 #include "pxr/base/gf/declare.h"
37 #include "pxr/base/gf/matrixData.h"
38 #include "pxr/base/gf/vec4d.h"
39 #include "pxr/base/gf/traits.h"
40 #include "pxr/base/gf/homogeneous.h"
41 #include "pxr/base/gf/limits.h"
42 #include "pxr/base/gf/math.h"
43 #include "pxr/base/gf/vec3d.h"
44 
45 #include <boost/functional/hash.hpp>
46 
47 #include <iosfwd>
48 #include <vector>
49 
50 PXR_NAMESPACE_OPEN_SCOPE
51 
52 template <>
53 struct GfIsGfMatrix<class GfMatrix4d> { static const bool value = true; };
54 
55 class GfMatrix4d;
56 class GfMatrix4f;
57 class GfQuatd;
58 class GfRotation;
59 class GfMatrix3d;
60 
89 {
90 public:
91  typedef double ScalarType;
92 
93  static const size_t numRows = 4;
94  static const size_t numColumns = 4;
95 
97  GfMatrix4d() = default;
98 
102  GfMatrix4d(double m00, double m01, double m02, double m03,
103  double m10, double m11, double m12, double m13,
104  double m20, double m21, double m22, double m23,
105  double m30, double m31, double m32, double m33) {
106  Set(m00, m01, m02, m03,
107  m10, m11, m12, m13,
108  m20, m21, m22, m23,
109  m30, m31, m32, m33);
110  }
111 
114  GfMatrix4d(const double m[4][4]) {
115  Set(m);
116  }
117 
120  explicit GfMatrix4d(double s) {
121  SetDiagonal(s);
122  }
123 
126  explicit GfMatrix4d(const GfVec4d& v) {
127  SetDiagonal(v);
128  }
129 
136  GF_API
137  explicit GfMatrix4d(const std::vector< std::vector<double> >& v);
138 
145  GF_API
146  explicit GfMatrix4d(const std::vector< std::vector<float> >& v);
147 
154  GF_API
155  explicit GfMatrix4d(const std::vector<double>& r0,
156  const std::vector<double>& r1,
157  const std::vector<double>& r2,
158  const std::vector<double>& r3);
159 
166  GF_API
167  explicit GfMatrix4d(const std::vector<float>& r0,
168  const std::vector<float>& r1,
169  const std::vector<float>& r2,
170  const std::vector<float>& r3);
171 
174  GF_API
175  GfMatrix4d(const GfRotation& rotate,
176  const GfVec3d& translate);
177 
180  GF_API
181  GfMatrix4d(const GfMatrix3d& rotmx,
182  const GfVec3d& translate);
184  GF_API
185  explicit GfMatrix4d(const class GfMatrix4f& m);
186 
188  void SetRow(int i, const GfVec4d & v) {
189  _mtx[i][0] = v[0];
190  _mtx[i][1] = v[1];
191  _mtx[i][2] = v[2];
192  _mtx[i][3] = v[3];
193  }
194 
196  void SetColumn(int i, const GfVec4d & v) {
197  _mtx[0][i] = v[0];
198  _mtx[1][i] = v[1];
199  _mtx[2][i] = v[2];
200  _mtx[3][i] = v[3];
201  }
202 
204  GfVec4d GetRow(int i) const {
205  return GfVec4d(_mtx[i][0], _mtx[i][1], _mtx[i][2], _mtx[i][3]);
206  }
207 
209  GfVec4d GetColumn(int i) const {
210  return GfVec4d(_mtx[0][i], _mtx[1][i], _mtx[2][i], _mtx[3][i]);
211  }
212 
216  GfMatrix4d& Set(double m00, double m01, double m02, double m03,
217  double m10, double m11, double m12, double m13,
218  double m20, double m21, double m22, double m23,
219  double m30, double m31, double m32, double m33) {
220  _mtx[0][0] = m00; _mtx[0][1] = m01; _mtx[0][2] = m02; _mtx[0][3] = m03;
221  _mtx[1][0] = m10; _mtx[1][1] = m11; _mtx[1][2] = m12; _mtx[1][3] = m13;
222  _mtx[2][0] = m20; _mtx[2][1] = m21; _mtx[2][2] = m22; _mtx[2][3] = m23;
223  _mtx[3][0] = m30; _mtx[3][1] = m31; _mtx[3][2] = m32; _mtx[3][3] = m33;
224  return *this;
225  }
226 
229  GfMatrix4d& Set(const double m[4][4]) {
230  _mtx[0][0] = m[0][0];
231  _mtx[0][1] = m[0][1];
232  _mtx[0][2] = m[0][2];
233  _mtx[0][3] = m[0][3];
234  _mtx[1][0] = m[1][0];
235  _mtx[1][1] = m[1][1];
236  _mtx[1][2] = m[1][2];
237  _mtx[1][3] = m[1][3];
238  _mtx[2][0] = m[2][0];
239  _mtx[2][1] = m[2][1];
240  _mtx[2][2] = m[2][2];
241  _mtx[2][3] = m[2][3];
242  _mtx[3][0] = m[3][0];
243  _mtx[3][1] = m[3][1];
244  _mtx[3][2] = m[3][2];
245  _mtx[3][3] = m[3][3];
246  return *this;
247  }
248 
251  return SetDiagonal(1);
252  }
253 
256  return SetDiagonal(0);
257  }
258 
260  GF_API
261  GfMatrix4d& SetDiagonal(double s);
262 
264  GF_API
265  GfMatrix4d& SetDiagonal(const GfVec4d&);
266 
269  GF_API
270  double* Get(double m[4][4]) const;
271 
274  double* data() {
275  return _mtx.GetData();
276  }
277 
280  const double* data() const {
281  return _mtx.GetData();
282  }
283 
285  double* GetArray() {
286  return _mtx.GetData();
287  }
288 
290  const double* GetArray() const {
291  return _mtx.GetData();
292  }
293 
297  double* operator [](int i) { return _mtx[i]; }
298 
302  const double* operator [](int i) const { return _mtx[i]; }
303 
305  friend inline size_t hash_value(GfMatrix4d const &m) {
306  int nElems = 4 * 4;
307  size_t h = 0;
308  const double *p = m.GetArray();
309  while (nElems--)
310  boost::hash_combine(h, *p++);
311  return h;
312  }
313 
316  GF_API
317  bool operator ==(const GfMatrix4d& m) const;
318 
321  GF_API
322  bool operator ==(const GfMatrix4f& m) const;
323 
326  bool operator !=(const GfMatrix4d& m) const {
327  return !(*this == m);
328  }
329 
332  bool operator !=(const GfMatrix4f& m) const {
333  return !(*this == m);
334  }
335 
337  GF_API
338  GfMatrix4d GetTranspose() const;
339 
345  GF_API
346  GfMatrix4d GetInverse(double* det = NULL, double eps = 0) const;
347 
349  GF_API
350  double GetDeterminant() const;
351 
354  void SetRow3(int i, const GfVec3d & v) {
355  _mtx[i][0] = v[0];
356  _mtx[i][1] = v[1];
357  _mtx[i][2] = v[2];
358  }
359 
361  GfVec3d GetRow3(int i) const {
362  return GfVec3d(_mtx[i][0], _mtx[i][1], _mtx[i][2]);
363  }
364 
368  double GetDeterminant3() const {
369  return _GetDeterminant3(0, 1, 2, 0, 1, 2);
370  }
371 
375  bool HasOrthogonalRows3() const {
376  // XXX Should add GfAreOrthogonal(v0, v1, v2) (which also
377  // GfRotation::Decompose() could use).
378  GfVec3d axis0(GetRow3(0)), axis1(GetRow3(1)), axis2(GetRow3(2));
379  return (GfAbs(GfDot(axis0, axis1)) < GF_MIN_ORTHO_TOLERANCE &&
380  GfAbs(GfDot(axis0, axis2)) < GF_MIN_ORTHO_TOLERANCE &&
381  GfAbs(GfDot(axis1, axis2)) < GF_MIN_ORTHO_TOLERANCE);
382  }
383 
392  GF_API
393  bool Orthonormalize(bool issueWarning=true);
394 
396  GF_API
397  GfMatrix4d GetOrthonormalized(bool issueWarning=true) const;
398 
402  GF_API
403  double GetHandedness() const;
404 
407  bool IsRightHanded() const {
408  return GetHandedness() == 1.0;
409  }
410 
413  bool IsLeftHanded() const {
414  return GetHandedness() == -1.0;
415  }
416 
418  GF_API
419  GfMatrix4d& operator *=(const GfMatrix4d& m);
420 
422  GF_API
423  GfMatrix4d& operator *=(double);
424 
426  friend GfMatrix4d operator *(const GfMatrix4d& m1, double d)
427  {
428  GfMatrix4d m = m1;
429  return m *= d;
430  }
431 
433  // Returns the product of a matrix and a double.
434  friend GfMatrix4d operator *(double d, const GfMatrix4d& m)
435  {
436  return m * d;
437  }
438 
440  GF_API
441  GfMatrix4d& operator +=(const GfMatrix4d& m);
442 
444  GF_API
445  GfMatrix4d& operator -=(const GfMatrix4d& m);
446 
448  GF_API
449  friend GfMatrix4d operator -(const GfMatrix4d& m);
450 
452  friend GfMatrix4d operator +(const GfMatrix4d& m1, const GfMatrix4d& m2)
453  {
454  GfMatrix4d tmp(m1);
455  tmp += m2;
456  return tmp;
457  }
458 
460  friend GfMatrix4d operator -(const GfMatrix4d& m1, const GfMatrix4d& m2)
461  {
462  GfMatrix4d tmp(m1);
463  tmp -= m2;
464  return tmp;
465  }
466 
468  friend GfMatrix4d operator *(const GfMatrix4d& m1, const GfMatrix4d& m2)
469  {
470  GfMatrix4d tmp(m1);
471  tmp *= m2;
472  return tmp;
473  }
474 
476  friend GfMatrix4d operator /(const GfMatrix4d& m1, const GfMatrix4d& m2)
477  {
478  return(m1 * m2.GetInverse());
479  }
480 
482  friend inline GfVec4d operator *(const GfMatrix4d& m, const GfVec4d& vec) {
483  return GfVec4d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1] + vec[2] * m._mtx[0][2] + vec[3] * m._mtx[0][3],
484  vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[1][2] + vec[3] * m._mtx[1][3],
485  vec[0] * m._mtx[2][0] + vec[1] * m._mtx[2][1] + vec[2] * m._mtx[2][2] + vec[3] * m._mtx[2][3],
486  vec[0] * m._mtx[3][0] + vec[1] * m._mtx[3][1] + vec[2] * m._mtx[3][2] + vec[3] * m._mtx[3][3]);
487  }
488 
490  friend inline GfVec4d operator *(const GfVec4d &vec, const GfMatrix4d& m) {
491  return GfVec4d(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0] + vec[2] * m._mtx[2][0] + vec[3] * m._mtx[3][0],
492  vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[2][1] + vec[3] * m._mtx[3][1],
493  vec[0] * m._mtx[0][2] + vec[1] * m._mtx[1][2] + vec[2] * m._mtx[2][2] + vec[3] * m._mtx[3][2],
494  vec[0] * m._mtx[0][3] + vec[1] * m._mtx[1][3] + vec[2] * m._mtx[2][3] + vec[3] * m._mtx[3][3]);
495  }
496 
499  GF_API
500  friend GfVec4f operator *(const GfMatrix4d& m, const GfVec4f& vec);
501 
504  GF_API
505  friend GfVec4f operator *(const GfVec4f &vec, const GfMatrix4d& m);
506 
508  GF_API
509  GfMatrix4d& SetScale(double scaleFactor);
510 
514  GF_API
516 
519 
522  GF_API
523  GfMatrix4d& SetRotate(const GfQuatd &rot);
524 
527  GF_API
528  GfMatrix4d& SetRotateOnly(const GfQuatd &rot);
529 
532  GF_API
533  GfMatrix4d& SetRotate(const GfRotation &rot);
534 
537  GF_API
538  GfMatrix4d& SetRotateOnly(const GfRotation &rot);
539 
542  GF_API
543  GfMatrix4d& SetRotate(const GfMatrix3d &mx);
544 
547  GF_API
548  GfMatrix4d& SetRotateOnly(const GfMatrix3d &mx);
549 
552  GF_API
553  GfMatrix4d& SetScale(const GfVec3d &scaleFactors);
554 
557  GF_API
558  GfMatrix4d& SetTranslate(const GfVec3d &trans);
559 
562  GF_API
564 
567  GF_API
568  GfMatrix4d& SetTransform(const GfRotation& rotate,
569  const GfVec3d& translate);
570 
573  GF_API
574  GfMatrix4d& SetTransform(const GfMatrix3d& rotmx,
575  const GfVec3d& translate);
576 
582  GF_API
583  GfMatrix4d& SetLookAt(const GfVec3d &eyePoint,
584  const GfVec3d &centerPoint,
585  const GfVec3d &upDirection);
586 
592  GF_API
593  GfMatrix4d& SetLookAt(const GfVec3d &eyePoint,
594  const GfRotation &orientation);
595 
610  GF_API
611  bool Factor(GfMatrix4d* r, GfVec3d* s, GfMatrix4d* u,
612  GfVec3d* t, GfMatrix4d* p,
613  double eps = 1e-10) const;
614 
618  return GfVec3d(_mtx[3][0], _mtx[3][1], _mtx[3][2]);
619  }
620 
626  GF_API
627  GfRotation ExtractRotation() const;
628 
634  GF_API
635  GfVec3d DecomposeRotation(const GfVec3d &axis0,
636  const GfVec3d &axis1,
637  const GfVec3d &axis2) const;
638 
644  GF_API
646 
650  GfVec3d Transform(const GfVec3d &vec) const {
651  return GfProject(GfVec4d(
652  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
653  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
654  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
655  vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3]));
656  }
657 
662  GfVec3f Transform(const GfVec3f &vec) const {
663  return GfVec3f(GfProject(GfVec4d(
664  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
665  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
666  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
667  vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3])));
668  }
669 
674  GfVec3d TransformDir(const GfVec3d &vec) const {
675  return GfVec3d(
676  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
677  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
678  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
679  }
680 
687  GfVec3f TransformDir(const GfVec3f &vec) const {
688  return GfVec3f(
689  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
690  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
691  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
692  }
693 
698  GfVec3d TransformAffine(const GfVec3d &vec) const {
699  return GfVec3d(
700  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
701  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
702  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
703  }
704 
709  GfVec3f TransformAffine(const GfVec3f &vec) const {
710  return GfVec3f(
711  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
712  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
713  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
714  }
716 
717 private:
720  GF_API
721  double _GetDeterminant3(size_t row1, size_t row2, size_t row3,
722  size_t col1, size_t col2, size_t col3) const;
723 
725  void _Jacobi3(GfVec3d *eigenvalues, GfVec3d eigenvectors[3]) const;
726 
729  void _SetRotateFromQuat(double r, const GfVec3d& i);
730 
731 
732 private:
734  GfMatrixData<double, 4, 4> _mtx;
735 
736  // Friend declarations
737  friend class GfMatrix4f;
738 };
739 
740 
744 GF_API
745 bool GfIsClose(GfMatrix4d const &m1, GfMatrix4d const &m2, double tolerance);
746 
749 GF_API std::ostream& operator<<(std::ostream &, GfMatrix4d const &);
750 
751 PXR_NAMESPACE_CLOSE_SCOPE
752 
753 #endif // GF_MATRIX4D_H
GfVec3f GfProject(const GfVec4f &v)
Projects homogeneous v into Euclidean space and returns the result as a Vec3f.
Definition: homogeneous.h:65
friend GfMatrix4d operator*(const GfMatrix4d &m1, double d)
Returns the product of a matrix and a double.
Definition: matrix4d.h:426
GfVec4d GetRow(int i) const
Gets a row of the matrix as a Vec4.
Definition: matrix4d.h:204
GfVec3d TransformAffine(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:698
Stores a 4x4 matrix of float elements.
Definition: matrix4f.h:88
GfVec3d ExtractTranslation() const
Returns the translation part of the matrix, defined as the first three elements of the last row...
Definition: matrix4d.h:617
bool IsRightHanded() const
Returns true if the vectors in the upper 3x3 matrix form a right-handed coordinate system...
Definition: matrix4d.h:407
bool GfIsClose(double a, double b, double epsilon)
Returns true if a and b are with epsilon of each other.
Definition: math.h:39
GfMatrix4d & Set(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33)
Sets the matrix from 16 independent double values, specified in row-major order.
Definition: matrix4d.h:216
GF_API GfMatrix4d & SetTranslateOnly(const GfVec3d &t)
Sets matrix to specify a translation by the vector trans, without clearing the rotation.
GF_API GfMatrix4d & SetScale(double scaleFactor)
Sets matrix to specify a uniform scaling by scaleFactor.
friend GfMatrix4d operator+(const GfMatrix4d &m1, const GfMatrix4d &m2)
Adds matrix m2 to m1.
Definition: matrix4d.h:452
GfMatrix4d & Set(const double m[4][4])
Sets the matrix from a 4x4 array of double values, specified in row-major order.
Definition: matrix4d.h:229
double * operator[](int i)
Accesses an indexed row i of the matrix as an array of 4 double values so that standard indexing (suc...
Definition: matrix4d.h:297
void SetColumn(int i, const GfVec4d &v)
Sets a column of the matrix from a Vec4.
Definition: matrix4d.h:196
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
GfVec3d GetRow3(int i) const
Gets a row of the matrix as a Vec3.
Definition: matrix4d.h:361
GF_API GfMatrix4d & SetRotate(const GfQuatd &rot)
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
const double * GetArray() const
Returns vector components as a const array of double values.
Definition: matrix4d.h:290
GF_API GfMatrix4d & SetDiagonal(double s)
Sets the matrix to s times the identity matrix.
GF_API GfMatrix4d & SetTransform(const GfRotation &rotate, const GfVec3d &translate)
Sets matrix to specify a rotation by rotate and a translation by translate.
void SetRow(int i, const GfVec4d &v)
Sets a row of the matrix from a Vec4.
Definition: matrix4d.h:188
GF_API GfMatrix4d RemoveScaleShear() const
Returns the matrix with any scaling or shearing removed, leaving only the rotation and translation...
void SetRow3(int i, const GfVec3d &v)
Sets a row of the matrix from a Vec3.
Definition: matrix4d.h:354
double GfAbs(double f)
Return abs(f).
Definition: math.h:112
friend GfMatrix4d operator/(const GfMatrix4d &m1, const GfMatrix4d &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
Definition: matrix4d.h:476
double * data()
Returns raw access to components of matrix as an array of double values.
Definition: matrix4d.h:274
GfMatrix4d(double s)
Constructor.
Definition: matrix4d.h:120
bool HasOrthogonalRows3() const
Returns true, if the row vectors of the upper 3x3 matrix form an orthogonal basis.
Definition: matrix4d.h:375
GF_API GfMatrix4d GetOrthonormalized(bool issueWarning=true) const
Returns an orthonormalized copy of the matrix.
#define GF_MIN_ORTHO_TOLERANCE
This constant is used to determine when a set of basis vectors is close to orthogonal.
Definition: limits.h:39
GF_API GfMatrix4d & operator+=(const GfMatrix4d &m)
Adds matrix m to this matrix.
GF_API double GetHandedness() const
Returns the sign of the determinant of the upper 3x3 matrix, i.e.
GF_API GfMatrix4d & SetLookAt(const GfVec3d &eyePoint, const GfVec3d &centerPoint, const GfVec3d &upDirection)
Sets the matrix to specify a viewing matrix from parameters similar to those used by gluLookAt(3G)...
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.
GfMatrix4d()=default
Default constructor. Leaves the matrix component values undefined.
GfVec4d GetColumn(int i) const
Gets a column of the matrix as a Vec4.
Definition: matrix4d.h:209
GF_API double * Get(double m[4][4]) const
Fills a 4x4 array of double values with the values in the matrix, specified in row-major order...
GfVec3f Transform(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:662
GfMatrix4d(const double m[4][4])
Constructor.
Definition: matrix4d.h:114
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
A metafunction with a static const bool member &#39;value&#39; that is true for GfMatrix types, like GfMatrix3d, GfMatrix4f, etc and false for all other types.
Definition: traits.h:40
GfMatrix4d & SetZero()
Sets the matrix to zero.
Definition: matrix4d.h:255
GF_API GfMatrix4d GetInverse(double *det=NULL, double eps=0) const
Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular.
GF_API bool Factor(GfMatrix4d *r, GfVec3d *s, GfMatrix4d *u, GfVec3d *t, GfMatrix4d *p, double eps=1e-10) const
Factors the matrix into 5 components:
GfVec3d TransformDir(const GfVec3d &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4d.h:674
GF_API friend GfMatrix4d operator-(const GfMatrix4d &m)
Returns the unary negation of matrix m.
GfMatrix4d & SetIdentity()
Sets the matrix to the identity matrix.
Definition: matrix4d.h:250
GF_API GfMatrix4d & SetRotateOnly(const GfQuatd &rot)
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
bool IsLeftHanded() const
Returns true if the vectors in the upper 3x3 matrix form a left-handed coordinate system...
Definition: matrix4d.h:413
GF_API bool Orthonormalize(bool issueWarning=true)
Makes the matrix orthonormal in place.
GF_API GfMatrix4d & operator-=(const GfMatrix4d &m)
Subtracts matrix m from this matrix.
GfMatrix4d(const GfVec4d &v)
Constructor.
Definition: matrix4d.h:126
const double * data() const
Returns const raw access to components of matrix as an array of double values.
Definition: matrix4d.h:280
GfVec3d Transform(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:650
GF_API GfMatrix4d GetTranspose() const
Returns the transpose of the matrix.
friend size_t hash_value(GfMatrix4d const &m)
Hash.
Definition: matrix4d.h:305
GfMatrix4d(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33)
Constructor.
Definition: matrix4d.h:102
double * GetArray()
Returns vector components as an array of double values.
Definition: matrix4d.h:285
GfVec3f TransformAffine(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:709
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
bool operator!=(const GfMatrix4d &m) const
Tests for element-wise matrix inequality.
Definition: matrix4d.h:326
GF_API GfMatrix3d ExtractRotationMatrix() const
Returns the rotation corresponding to this matrix.
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
GF_API GfMatrix4d & operator*=(const GfMatrix4d &m)
Post-multiplies matrix m into this matrix.
GF_API GfMatrix4d & SetTranslate(const GfVec3d &trans)
Sets matrix to specify a translation by the vector trans, and clears the rotation.
GfVec3f TransformDir(const GfVec3f &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4d.h:687
Stores a 3x3 matrix of double elements.
Definition: matrix3d.h:82
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients...
Definition: quatd.h:60
GF_API GfRotation ExtractRotation() const
Returns the rotation corresponding to this matrix.
GF_API bool operator==(const GfMatrix4d &m) const
Tests for element-wise matrix equality.
Basic type: 3-space rotation specification.
Definition: rotation.h:55
double GetDeterminant3() const
Returns the determinant of the upper 3x3 matrix.
Definition: matrix4d.h:368
GfHalf GfDot(GfHalf a, GfHalf b)
Returns the dot (inner) product of two vectors.
Definition: half.h:55
GF_API double GetDeterminant() const
Returns the determinant of the matrix.