matrix4f.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 PXR_BASE_GF_MATRIX4F_H
29 #define PXR_BASE_GF_MATRIX4F_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/vec4f.h"
39 #include "pxr/base/gf/traits.h"
41 #include "pxr/base/gf/limits.h"
42 #include "pxr/base/gf/math.h"
43 #include "pxr/base/gf/vec3f.h"
44 #include "pxr/base/tf/hash.h"
45 
46 #include <iosfwd>
47 #include <vector>
48 
49 PXR_NAMESPACE_OPEN_SCOPE
50 
51 template <>
52 struct GfIsGfMatrix<class GfMatrix4f> { static const bool value = true; };
53 
54 class GfMatrix4d;
55 class GfMatrix4f;
56 class GfQuatf;
57 class GfRotation;
58 class GfMatrix3f;
59 
88 {
89 public:
90  typedef float ScalarType;
91 
92  static const size_t numRows = 4;
93  static const size_t numColumns = 4;
94 
96  GfMatrix4f() = default;
97 
101  GfMatrix4f(float m00, float m01, float m02, float m03,
102  float m10, float m11, float m12, float m13,
103  float m20, float m21, float m22, float m23,
104  float m30, float m31, float m32, float m33) {
105  Set(m00, m01, m02, m03,
106  m10, m11, m12, m13,
107  m20, m21, m22, m23,
108  m30, m31, m32, m33);
109  }
110 
113  GfMatrix4f(const float m[4][4]) {
114  Set(m);
115  }
116 
119  explicit GfMatrix4f(float s) {
120  SetDiagonal(s);
121  }
122 
125  explicit GfMatrix4f(const GfVec4f& v) {
126  SetDiagonal(v);
127  }
128 
135  GF_API
136  explicit GfMatrix4f(const std::vector< std::vector<double> >& v);
137 
144  GF_API
145  explicit GfMatrix4f(const std::vector< std::vector<float> >& v);
146 
153  GF_API
154  explicit GfMatrix4f(const std::vector<double>& r0,
155  const std::vector<double>& r1,
156  const std::vector<double>& r2,
157  const std::vector<double>& r3);
158 
165  GF_API
166  explicit GfMatrix4f(const std::vector<float>& r0,
167  const std::vector<float>& r1,
168  const std::vector<float>& r2,
169  const std::vector<float>& r3);
170 
173  GF_API
174  GfMatrix4f(const GfRotation& rotate,
175  const GfVec3f& translate);
176 
179  GF_API
180  GfMatrix4f(const GfMatrix3f& rotmx,
181  const GfVec3f& translate);
183  GF_API
184  explicit GfMatrix4f(const class GfMatrix4d& m);
185 
187  void SetRow(int i, const GfVec4f & v) {
188  _mtx[i][0] = v[0];
189  _mtx[i][1] = v[1];
190  _mtx[i][2] = v[2];
191  _mtx[i][3] = v[3];
192  }
193 
195  void SetColumn(int i, const GfVec4f & v) {
196  _mtx[0][i] = v[0];
197  _mtx[1][i] = v[1];
198  _mtx[2][i] = v[2];
199  _mtx[3][i] = v[3];
200  }
201 
203  GfVec4f GetRow(int i) const {
204  return GfVec4f(_mtx[i][0], _mtx[i][1], _mtx[i][2], _mtx[i][3]);
205  }
206 
208  GfVec4f GetColumn(int i) const {
209  return GfVec4f(_mtx[0][i], _mtx[1][i], _mtx[2][i], _mtx[3][i]);
210  }
211 
215  GfMatrix4f& Set(float m00, float m01, float m02, float m03,
216  float m10, float m11, float m12, float m13,
217  float m20, float m21, float m22, float m23,
218  float m30, float m31, float m32, float m33) {
219  _mtx[0][0] = m00; _mtx[0][1] = m01; _mtx[0][2] = m02; _mtx[0][3] = m03;
220  _mtx[1][0] = m10; _mtx[1][1] = m11; _mtx[1][2] = m12; _mtx[1][3] = m13;
221  _mtx[2][0] = m20; _mtx[2][1] = m21; _mtx[2][2] = m22; _mtx[2][3] = m23;
222  _mtx[3][0] = m30; _mtx[3][1] = m31; _mtx[3][2] = m32; _mtx[3][3] = m33;
223  return *this;
224  }
225 
228  GfMatrix4f& Set(const float m[4][4]) {
229  _mtx[0][0] = m[0][0];
230  _mtx[0][1] = m[0][1];
231  _mtx[0][2] = m[0][2];
232  _mtx[0][3] = m[0][3];
233  _mtx[1][0] = m[1][0];
234  _mtx[1][1] = m[1][1];
235  _mtx[1][2] = m[1][2];
236  _mtx[1][3] = m[1][3];
237  _mtx[2][0] = m[2][0];
238  _mtx[2][1] = m[2][1];
239  _mtx[2][2] = m[2][2];
240  _mtx[2][3] = m[2][3];
241  _mtx[3][0] = m[3][0];
242  _mtx[3][1] = m[3][1];
243  _mtx[3][2] = m[3][2];
244  _mtx[3][3] = m[3][3];
245  return *this;
246  }
247 
250  return SetDiagonal(1);
251  }
252 
255  return SetDiagonal(0);
256  }
257 
259  GF_API
260  GfMatrix4f& SetDiagonal(float s);
261 
263  GF_API
264  GfMatrix4f& SetDiagonal(const GfVec4f&);
265 
268  GF_API
269  float* Get(float m[4][4]) const;
270 
273  float* data() {
274  return _mtx.GetData();
275  }
276 
279  const float* data() const {
280  return _mtx.GetData();
281  }
282 
284  float* GetArray() {
285  return _mtx.GetData();
286  }
287 
289  const float* GetArray() const {
290  return _mtx.GetData();
291  }
292 
296  float* operator [](int i) { return _mtx[i]; }
297 
301  const float* operator [](int i) const { return _mtx[i]; }
302 
304  friend inline size_t hash_value(GfMatrix4f const &m) {
305  return TfHash::Combine(
306  m._mtx[0][0],
307  m._mtx[0][1],
308  m._mtx[0][2],
309  m._mtx[0][3],
310  m._mtx[1][0],
311  m._mtx[1][1],
312  m._mtx[1][2],
313  m._mtx[1][3],
314  m._mtx[2][0],
315  m._mtx[2][1],
316  m._mtx[2][2],
317  m._mtx[2][3],
318  m._mtx[3][0],
319  m._mtx[3][1],
320  m._mtx[3][2],
321  m._mtx[3][3]
322  );
323  }
324 
327  GF_API
328  bool operator ==(const GfMatrix4d& m) const;
329 
332  GF_API
333  bool operator ==(const GfMatrix4f& m) const;
334 
337  bool operator !=(const GfMatrix4d& m) const {
338  return !(*this == m);
339  }
340 
343  bool operator !=(const GfMatrix4f& m) const {
344  return !(*this == m);
345  }
346 
348  GF_API
349  GfMatrix4f GetTranspose() const;
350 
356  GF_API
357  GfMatrix4f GetInverse(double* det = NULL, double eps = 0) const;
358 
360  GF_API
361  double GetDeterminant() const;
362 
365  void SetRow3(int i, const GfVec3f & v) {
366  _mtx[i][0] = v[0];
367  _mtx[i][1] = v[1];
368  _mtx[i][2] = v[2];
369  }
370 
372  GfVec3f GetRow3(int i) const {
373  return GfVec3f(_mtx[i][0], _mtx[i][1], _mtx[i][2]);
374  }
375 
379  double GetDeterminant3() const {
380  return _GetDeterminant3(0, 1, 2, 0, 1, 2);
381  }
382 
386  bool HasOrthogonalRows3() const {
387  // XXX Should add GfAreOrthogonal(v0, v1, v2) (which also
388  // GfRotation::Decompose() could use).
389  GfVec3f axis0(GetRow3(0)), axis1(GetRow3(1)), axis2(GetRow3(2));
390  return (GfAbs(GfDot(axis0, axis1)) < GF_MIN_ORTHO_TOLERANCE &&
391  GfAbs(GfDot(axis0, axis2)) < GF_MIN_ORTHO_TOLERANCE &&
392  GfAbs(GfDot(axis1, axis2)) < GF_MIN_ORTHO_TOLERANCE);
393  }
394 
403  GF_API
404  bool Orthonormalize(bool issueWarning=true);
405 
407  GF_API
408  GfMatrix4f GetOrthonormalized(bool issueWarning=true) const;
409 
413  GF_API
414  double GetHandedness() const;
415 
418  bool IsRightHanded() const {
419  return GetHandedness() == 1.0;
420  }
421 
424  bool IsLeftHanded() const {
425  return GetHandedness() == -1.0;
426  }
427 
429  GF_API
430  GfMatrix4f& operator *=(const GfMatrix4f& m);
431 
433  GF_API
434  GfMatrix4f& operator *=(double);
435 
437  friend GfMatrix4f operator *(const GfMatrix4f& m1, double d)
438  {
439  GfMatrix4f m = m1;
440  return m *= d;
441  }
442 
444  // Returns the product of a matrix and a float.
445  friend GfMatrix4f operator *(double d, const GfMatrix4f& m)
446  {
447  return m * d;
448  }
449 
451  GF_API
452  GfMatrix4f& operator +=(const GfMatrix4f& m);
453 
455  GF_API
456  GfMatrix4f& operator -=(const GfMatrix4f& m);
457 
459  GF_API
460  friend GfMatrix4f operator -(const GfMatrix4f& m);
461 
463  friend GfMatrix4f operator +(const GfMatrix4f& m1, const GfMatrix4f& m2)
464  {
465  GfMatrix4f tmp(m1);
466  tmp += m2;
467  return tmp;
468  }
469 
471  friend GfMatrix4f operator -(const GfMatrix4f& m1, const GfMatrix4f& m2)
472  {
473  GfMatrix4f tmp(m1);
474  tmp -= m2;
475  return tmp;
476  }
477 
479  friend GfMatrix4f operator *(const GfMatrix4f& m1, const GfMatrix4f& m2)
480  {
481  GfMatrix4f tmp(m1);
482  tmp *= m2;
483  return tmp;
484  }
485 
487  friend GfMatrix4f operator /(const GfMatrix4f& m1, const GfMatrix4f& m2)
488  {
489  return(m1 * m2.GetInverse());
490  }
491 
493  friend inline GfVec4f operator *(const GfMatrix4f& m, const GfVec4f& vec) {
494  return GfVec4f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[0][1] + vec[2] * m._mtx[0][2] + vec[3] * m._mtx[0][3],
495  vec[0] * m._mtx[1][0] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[1][2] + vec[3] * m._mtx[1][3],
496  vec[0] * m._mtx[2][0] + vec[1] * m._mtx[2][1] + vec[2] * m._mtx[2][2] + vec[3] * m._mtx[2][3],
497  vec[0] * m._mtx[3][0] + vec[1] * m._mtx[3][1] + vec[2] * m._mtx[3][2] + vec[3] * m._mtx[3][3]);
498  }
499 
501  friend inline GfVec4f operator *(const GfVec4f &vec, const GfMatrix4f& m) {
502  return GfVec4f(vec[0] * m._mtx[0][0] + vec[1] * m._mtx[1][0] + vec[2] * m._mtx[2][0] + vec[3] * m._mtx[3][0],
503  vec[0] * m._mtx[0][1] + vec[1] * m._mtx[1][1] + vec[2] * m._mtx[2][1] + vec[3] * m._mtx[3][1],
504  vec[0] * m._mtx[0][2] + vec[1] * m._mtx[1][2] + vec[2] * m._mtx[2][2] + vec[3] * m._mtx[3][2],
505  vec[0] * m._mtx[0][3] + vec[1] * m._mtx[1][3] + vec[2] * m._mtx[2][3] + vec[3] * m._mtx[3][3]);
506  }
507 
509  GF_API
510  GfMatrix4f& SetScale(float scaleFactor);
511 
515  GF_API
517 
520 
523  GF_API
524  GfMatrix4f& SetRotate(const GfQuatf &rot);
525 
528  GF_API
529  GfMatrix4f& SetRotateOnly(const GfQuatf &rot);
530 
533  GF_API
534  GfMatrix4f& SetRotate(const GfRotation &rot);
535 
538  GF_API
539  GfMatrix4f& SetRotateOnly(const GfRotation &rot);
540 
543  GF_API
544  GfMatrix4f& SetRotate(const GfMatrix3f &mx);
545 
548  GF_API
549  GfMatrix4f& SetRotateOnly(const GfMatrix3f &mx);
550 
553  GF_API
554  GfMatrix4f& SetScale(const GfVec3f &scaleFactors);
555 
558  GF_API
559  GfMatrix4f& SetTranslate(const GfVec3f &trans);
560 
563  GF_API
565 
568  GF_API
569  GfMatrix4f& SetTransform(const GfRotation& rotate,
570  const GfVec3f& translate);
571 
574  GF_API
575  GfMatrix4f& SetTransform(const GfMatrix3f& rotmx,
576  const GfVec3f& translate);
577 
583  GF_API
584  GfMatrix4f& SetLookAt(const GfVec3f &eyePoint,
585  const GfVec3f &centerPoint,
586  const GfVec3f &upDirection);
587 
593  GF_API
594  GfMatrix4f& SetLookAt(const GfVec3f &eyePoint,
595  const GfRotation &orientation);
596 
611  GF_API
612  bool Factor(GfMatrix4f* r, GfVec3f* s, GfMatrix4f* u,
613  GfVec3f* t, GfMatrix4f* p,
614  float eps = 1e-5) const;
615 
619  return GfVec3f(_mtx[3][0], _mtx[3][1], _mtx[3][2]);
620  }
621 
627  GF_API
628  GfRotation ExtractRotation() const;
629 
635  GF_API
637 
643  GF_API
644  GfVec3f DecomposeRotation(const GfVec3f &axis0,
645  const GfVec3f &axis1,
646  const GfVec3f &axis2) const;
647 
653  GF_API
655 
659  GfVec3d Transform(const GfVec3d &vec) const {
660  return GfProject(GfVec4d(
661  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
662  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
663  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
664  vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3]));
665  }
666 
671  GfVec3f Transform(const GfVec3f &vec) const {
672  return (GfProject(GfVec4f(
673  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
674  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
675  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
676  vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3])));
677  }
678 
683  GfVec3d TransformDir(const GfVec3d &vec) const {
684  return GfVec3d(
685  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
686  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
687  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
688  }
689 
696  GfVec3f TransformDir(const GfVec3f &vec) const {
697  return GfVec3f(
698  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
699  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
700  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
701  }
702 
707  GfVec3d TransformAffine(const GfVec3d &vec) const {
708  return GfVec3d(
709  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
710  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
711  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
712  }
713 
718  GfVec3f TransformAffine(const GfVec3f &vec) const {
719  return GfVec3f(
720  vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
721  vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
722  vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
723  }
725 
726 private:
729  GF_API
730  double _GetDeterminant3(size_t row1, size_t row2, size_t row3,
731  size_t col1, size_t col2, size_t col3) const;
732 
734  void _Jacobi3(GfVec3d *eigenvalues, GfVec3d eigenvectors[3]) const;
735 
738  void _SetRotateFromQuat(float r, const GfVec3f& i);
739 
740 
741 private:
744 
745  // Friend declarations
746  friend class GfMatrix4d;
747 };
748 
749 
753 GF_API
754 bool GfIsClose(GfMatrix4f const &m1, GfMatrix4f const &m2, double tolerance);
755 
758 GF_API std::ostream& operator<<(std::ostream &, GfMatrix4f const &);
759 
760 PXR_NAMESPACE_CLOSE_SCOPE
761 
762 #endif // PXR_BASE_GF_MATRIX4F_H
GfVec3f GfProject(const GfVec4f &v)
Projects homogeneous v into Euclidean space and returns the result as a Vec3f.
Definition: homogeneous.h:65
GF_API GfMatrix4f & operator *=(const GfMatrix4f &m)
Post-multiplies matrix m into this matrix.
GF_API GfMatrix4f & SetTranslateOnly(const GfVec3f &t)
Sets matrix to specify a translation by the vector trans, without clearing the rotation.
GF_API GfMatrix4f GetOrthonormalized(bool issueWarning=true) const
Returns an orthonormalized copy of the matrix.
bool IsLeftHanded() const
Returns true if the vectors in the upper 3x3 matrix form a left-handed coordinate system.
Definition: matrix4f.h:424
Stores a 4x4 matrix of float elements.
Definition: matrix4f.h:87
float * operator [](int i)
Accesses an indexed row i of the matrix as an array of 4 float values so that standard indexing (such...
Definition: matrix4f.h:296
friend GfVec4f operator *(const GfMatrix4f &m, const GfVec4f &vec)
Returns the product of a matrix m and a column vector vec.
Definition: matrix4f.h:493
GfVec3f GetRow3(int i) const
Gets a row of the matrix as a Vec3.
Definition: matrix4f.h:372
const float * GetArray() const
Returns vector components as a const array of float values.
Definition: matrix4f.h:289
bool HasOrthogonalRows3() const
Returns true, if the row vectors of the upper 3x3 matrix form an orthogonal basis.
Definition: matrix4f.h:386
friend GfMatrix4f operator+(const GfMatrix4f &m1, const GfMatrix4f &m2)
Adds matrix m2 to m1.
Definition: matrix4f.h:463
GF_API double GetDeterminant() const
Returns the determinant of the matrix.
GF_API double GetHandedness() const
Returns the sign of the determinant of the upper 3x3 matrix, i.e.
friend GfMatrix4f operator -(const GfMatrix4f &m1, const GfMatrix4f &m2)
Subtracts matrix m2 from m1.
Definition: matrix4f.h:471
GfVec3f Transform(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4f.h:671
Assorted mathematical utility functions.
GF_API GfMatrix4f & SetTranslate(const GfVec3f &trans)
Sets matrix to specify a translation by the vector trans, and clears the rotation.
float * data()
Returns raw access to components of matrix as an array of float values.
Definition: matrix4f.h:273
Basic type for a vector of 3 float components.
Definition: vec3f.h:62
Basic type for a vector of 4 double components.
Definition: vec4d.h:62
Declares Gf types.
GfVec4f GetColumn(int i) const
Gets a column of the matrix as a Vec4.
Definition: matrix4f.h:208
double GfAbs(double f)
Return abs(f).
Definition: math.h:115
GfVec3f TransformAffine(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4f.h:718
GF_API GfMatrix4f & SetLookAt(const GfVec3f &eyePoint, const GfVec3f &centerPoint, const GfVec3f &upDirection)
Sets the matrix to specify a viewing matrix from parameters similar to those used by gluLookAt(3G).
GfVec3d Transform(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4f.h:659
GfVec3d TransformDir(const GfVec3d &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4f.h:683
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatf.h:59
void SetColumn(int i, const GfVec4f &v)
Sets a column of the matrix from a Vec4.
Definition: matrix4f.h:195
GF_API bool operator==(const GfMatrix4d &m) const
Tests for element-wise matrix equality.
#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 GfMatrix4f 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 GfMatrix4f & SetRotate(const GfQuatf &rot)
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
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.
bool IsRightHanded() const
Returns true if the vectors in the upper 3x3 matrix form a right-handed coordinate system.
Definition: matrix4f.h:418
GF_API std::ostream & operator<<(std::ostream &, GfMatrix4f const &)
Output a GfMatrix4f.
Stores a 3x3 matrix of float elements.
Definition: matrix3f.h:81
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:519
GfMatrix4f(const float m[4][4])
Constructor.
Definition: matrix4f.h:113
GF_API GfMatrix4f RemoveScaleShear() const
Returns the matrix with any scaling or shearing removed, leaving only the rotation and translation.
GF_API GfMatrix4f & SetDiagonal(float s)
Sets the matrix to s times the identity matrix.
GfMatrix4f()=default
Default constructor. Leaves the matrix component values undefined.
friend GfMatrix4f operator *(const GfMatrix4f &m1, double d)
Returns the product of a matrix and a float.
Definition: matrix4f.h:437
T * GetData()
Return a pointer to the start of all the data.
Definition: matrixData.h:50
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:87
A metafunction with a static const bool member 'value' that is true for GfMatrix types,...
Definition: traits.h:42
friend size_t hash_value(GfMatrix4f const &m)
Hash.
Definition: matrix4f.h:304
GF_API GfRotation ExtractRotation() const
Returns the rotation corresponding to this matrix.
GF_API GfMatrix4f & SetScale(float scaleFactor)
Sets matrix to specify a uniform scaling by scaleFactor.
GfVec3f ExtractTranslation() const
Returns the translation part of the matrix, defined as the first three elements of the last row.
Definition: matrix4f.h:618
Utility functions for GfVec4f and GfVec4d as homogeneous vectors.
GF_API GfMatrix4f & operator+=(const GfMatrix4f &m)
Adds matrix m to this matrix.
GfMatrix4f & Set(const float m[4][4])
Sets the matrix from a 4x4 array of float values, specified in row-major order.
Definition: matrix4f.h:228
double GfDot(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatd.h:277
GF_API GfMatrix4f & operator -=(const GfMatrix4f &m)
Subtracts matrix m from this matrix.
GF_API GfMatrix3f ExtractRotationMatrix() const
Returns the rotation corresponding to this matrix.
GfMatrix4f(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
Constructor.
Definition: matrix4f.h:101
GF_API GfQuatf ExtractRotationQuat() const
Return the rotation corresponding to this matrix as a quaternion.
GF_API float * Get(float m[4][4]) const
Fills a 4x4 array of float values with the values in the matrix, specified in row-major order.
Basic type for a vector of 4 float components.
Definition: vec4f.h:62
float * GetArray()
Returns vector components as an array of float values.
Definition: matrix4f.h:284
friend GfVec4f operator *(const GfVec4f &vec, const GfMatrix4f &m)
Returns the product of row vector vec and a matrix m.
Definition: matrix4f.h:501
const float * data() const
Returns const raw access to components of matrix as an array of float values.
Definition: matrix4f.h:279
GfMatrix4f(float s)
Constructor.
Definition: matrix4f.h:119
GfMatrix4f & SetIdentity()
Sets the matrix to the identity matrix.
Definition: matrix4f.h:249
GF_API bool Orthonormalize(bool issueWarning=true)
Makes the matrix orthonormal in place.
friend GfMatrix4f operator/(const GfMatrix4f &m1, const GfMatrix4f &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
Definition: matrix4f.h:487
bool operator !=(const GfMatrix4f &m) const
Tests for element-wise matrix inequality.
Definition: matrix4f.h:343
void SetRow(int i, const GfVec4f &v)
Sets a row of the matrix from a Vec4.
Definition: matrix4f.h:187
bool operator !=(const GfMatrix4d &m) const
Tests for element-wise matrix inequality.
Definition: matrix4f.h:337
GF_API bool GfIsClose(GfMatrix4f const &m1, GfMatrix4f const &m2, double tolerance)
Tests for equality within a given tolerance, returning true if the difference between each component ...
Basic type for a vector of 3 double components.
Definition: vec3d.h:62
Defines useful mathematical limits.
GF_API GfMatrix4f GetTranspose() const
Returns the transpose of the matrix.
GfMatrix4f & Set(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
Sets the matrix from 16 independent float values, specified in row-major order.
Definition: matrix4f.h:215
friend GfMatrix4f operator *(const GfMatrix4f &m1, const GfMatrix4f &m2)
Multiplies matrix m1 by m2.
Definition: matrix4f.h:479
GF_API GfMatrix4f & SetRotateOnly(const GfQuatf &rot)
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
GfVec3d TransformAffine(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4f.h:707
GF_API GfMatrix4f & SetTransform(const GfRotation &rotate, const GfVec3f &translate)
Sets matrix to specify a rotation by rotate and a translation by translate.
GfMatrix4f(const GfVec4f &v)
Constructor.
Definition: matrix4f.h:125
GF_API bool Factor(GfMatrix4f *r, GfVec3f *s, GfMatrix4f *u, GfVec3f *t, GfMatrix4f *p, float eps=1e-5) const
Factors the matrix into 5 components:
Basic type: 3-space rotation specification.
Definition: rotation.h:54
void SetRow3(int i, const GfVec3f &v)
Sets a row of the matrix from a Vec3.
Definition: matrix4f.h:365
GfVec4f GetRow(int i) const
Gets a row of the matrix as a Vec4.
Definition: matrix4f.h:203
double GetDeterminant3() const
Returns the determinant of the upper 3x3 matrix.
Definition: matrix4f.h:379
GF_API friend GfMatrix4f operator -(const GfMatrix4f &m)
Returns the unary negation of matrix m.
GfVec3f TransformDir(const GfVec3f &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4f.h:696
const float * operator [](int i) const
Accesses an indexed row i of the matrix as an array of 4 float values so that standard indexing (such...
Definition: matrix4f.h:301
GfMatrix4f & SetZero()
Sets the matrix to zero.
Definition: matrix4f.h:254