Loading...
Searching...
No Matches
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 PXR_BASE_GF_MATRIX4D_H
29#define PXR_BASE_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"
41#include "pxr/base/gf/limits.h"
42#include "pxr/base/gf/math.h"
43#include "pxr/base/gf/vec3d.h"
44#include "pxr/base/tf/hash.h"
45
46#include <iosfwd>
47#include <vector>
48
49PXR_NAMESPACE_OPEN_SCOPE
50
51template <>
52struct GfIsGfMatrix<class GfMatrix4d> { static const bool value = true; };
53
54class GfMatrix4d;
55class GfMatrix4f;
56class GfQuatd;
57class GfRotation;
58class GfMatrix3d;
59
88{
89public:
90 typedef double ScalarType;
91
92 static const size_t numRows = 4;
93 static const size_t numColumns = 4;
94
96 GfMatrix4d() = default;
97
101 GfMatrix4d(double m00, double m01, double m02, double m03,
102 double m10, double m11, double m12, double m13,
103 double m20, double m21, double m22, double m23,
104 double m30, double m31, double m32, double 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 GfMatrix4d(const double m[4][4]) {
114 Set(m);
115 }
116
119 explicit GfMatrix4d(double s) {
120 SetDiagonal(s);
121 }
122
125 explicit GfMatrix4d(const GfVec4d& v) {
126 SetDiagonal(v);
127 }
128
135 GF_API
136 explicit GfMatrix4d(const std::vector< std::vector<double> >& v);
137
144 GF_API
145 explicit GfMatrix4d(const std::vector< std::vector<float> >& v);
146
153 GF_API
154 explicit GfMatrix4d(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 GfMatrix4d(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 GfMatrix4d(const GfRotation& rotate,
175 const GfVec3d& translate);
176
179 GF_API
180 GfMatrix4d(const GfMatrix3d& rotmx,
181 const GfVec3d& translate);
183 GF_API
184 explicit GfMatrix4d(const class GfMatrix4f& m);
185
187 void SetRow(int i, const GfVec4d & 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 GfVec4d & 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 GfVec4d GetRow(int i) const {
204 return GfVec4d(_mtx[i][0], _mtx[i][1], _mtx[i][2], _mtx[i][3]);
205 }
206
208 GfVec4d GetColumn(int i) const {
209 return GfVec4d(_mtx[0][i], _mtx[1][i], _mtx[2][i], _mtx[3][i]);
210 }
211
215 GfMatrix4d& Set(double m00, double m01, double m02, double m03,
216 double m10, double m11, double m12, double m13,
217 double m20, double m21, double m22, double m23,
218 double m30, double m31, double m32, double 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 GfMatrix4d& Set(const double 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
261
263 GF_API
265
268 GF_API
269 double* Get(double m[4][4]) const;
270
273 double* data() {
274 return _mtx.GetData();
275 }
276
279 const double* data() const {
280 return _mtx.GetData();
281 }
282
284 double* GetArray() {
285 return _mtx.GetData();
286 }
287
289 const double* GetArray() const {
290 return _mtx.GetData();
291 }
292
296 double* operator [](int i) { return _mtx[i]; }
297
301 const double* operator [](int i) const { return _mtx[i]; }
302
304 friend inline size_t hash_value(GfMatrix4d 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
350
356 GF_API
357 GfMatrix4d GetInverse(double* det = NULL, double eps = 0) const;
358
360 GF_API
361 double GetDeterminant() const;
362
365 void SetRow3(int i, const GfVec3d & v) {
366 _mtx[i][0] = v[0];
367 _mtx[i][1] = v[1];
368 _mtx[i][2] = v[2];
369 }
370
372 GfVec3d GetRow3(int i) const {
373 return GfVec3d(_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 GfVec3d 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 GfMatrix4d 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
431
433 GF_API
435
437 friend GfMatrix4d operator *(const GfMatrix4d& m1, double d)
438 {
439 GfMatrix4d m = m1;
440 return m *= d;
441 }
442
444 // Returns the product of a matrix and a double.
445 friend GfMatrix4d operator *(double d, const GfMatrix4d& m)
446 {
447 return m * d;
448 }
449
451 GF_API
453
455 GF_API
457
459 GF_API
461
463 friend GfMatrix4d operator +(const GfMatrix4d& m1, const GfMatrix4d& m2)
464 {
465 GfMatrix4d tmp(m1);
466 tmp += m2;
467 return tmp;
468 }
469
471 friend GfMatrix4d operator -(const GfMatrix4d& m1, const GfMatrix4d& m2)
472 {
473 GfMatrix4d tmp(m1);
474 tmp -= m2;
475 return tmp;
476 }
477
479 friend GfMatrix4d operator *(const GfMatrix4d& m1, const GfMatrix4d& m2)
480 {
481 GfMatrix4d tmp(m1);
482 tmp *= m2;
483 return tmp;
484 }
485
487 friend GfMatrix4d operator /(const GfMatrix4d& m1, const GfMatrix4d& m2)
488 {
489 return(m1 * m2.GetInverse());
490 }
491
493 friend inline GfVec4d operator *(const GfMatrix4d& m, const GfVec4d& vec) {
494 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],
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 GfVec4d operator *(const GfVec4d &vec, const GfMatrix4d& m) {
502 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],
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
510 GF_API
511 friend GfVec4f operator *(const GfMatrix4d& m, const GfVec4f& vec);
512
515 GF_API
516 friend GfVec4f operator *(const GfVec4f &vec, const GfMatrix4d& m);
517
519 GF_API
520 GfMatrix4d& SetScale(double scaleFactor);
521
525 GF_API
527
530
533 GF_API
535
538 GF_API
540
543 GF_API
545
548 GF_API
550
553 GF_API
555
558 GF_API
560
563 GF_API
564 GfMatrix4d& SetScale(const GfVec3d &scaleFactors);
565
568 GF_API
570
573 GF_API
575
578 GF_API
580 const GfVec3d& translate);
581
584 GF_API
586 const GfVec3d& translate);
587
593 GF_API
594 GfMatrix4d& SetLookAt(const GfVec3d &eyePoint,
595 const GfVec3d &centerPoint,
596 const GfVec3d &upDirection);
597
603 GF_API
604 GfMatrix4d& SetLookAt(const GfVec3d &eyePoint,
605 const GfRotation &orientation);
606
621 GF_API
623 GfVec3d* t, GfMatrix4d* p,
624 double eps = 1e-10) const;
625
629 return GfVec3d(_mtx[3][0], _mtx[3][1], _mtx[3][2]);
630 }
631
637 GF_API
639
645 GF_API
647
653 GF_API
655 const GfVec3d &axis1,
656 const GfVec3d &axis2) const;
657
663 GF_API
665
669 GfVec3d Transform(const GfVec3d &vec) const {
670 return GfProject(GfVec4d(
671 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
672 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
673 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
674 vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3]));
675 }
676
681 GfVec3f Transform(const GfVec3f &vec) const {
683 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
684 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
685 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2],
686 vec[0] * _mtx[0][3] + vec[1] * _mtx[1][3] + vec[2] * _mtx[2][3] + _mtx[3][3])));
687 }
688
693 GfVec3d TransformDir(const GfVec3d &vec) const {
694 return GfVec3d(
695 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
696 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
697 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
698 }
699
706 GfVec3f TransformDir(const GfVec3f &vec) const {
707 return GfVec3f(
708 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0],
709 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1],
710 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2]);
711 }
712
717 GfVec3d TransformAffine(const GfVec3d &vec) const {
718 return GfVec3d(
719 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
720 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
721 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
722 }
723
728 GfVec3f TransformAffine(const GfVec3f &vec) const {
729 return GfVec3f(
730 vec[0] * _mtx[0][0] + vec[1] * _mtx[1][0] + vec[2] * _mtx[2][0] + _mtx[3][0],
731 vec[0] * _mtx[0][1] + vec[1] * _mtx[1][1] + vec[2] * _mtx[2][1] + _mtx[3][1],
732 vec[0] * _mtx[0][2] + vec[1] * _mtx[1][2] + vec[2] * _mtx[2][2] + _mtx[3][2]);
733 }
735
736private:
739 GF_API
740 double _GetDeterminant3(size_t row1, size_t row2, size_t row3,
741 size_t col1, size_t col2, size_t col3) const;
742
744 void _Jacobi3(GfVec3d *eigenvalues, GfVec3d eigenvectors[3]) const;
745
748 void _SetRotateFromQuat(double r, const GfVec3d& i);
749
750
751private:
754
755 // Friend declarations
756 friend class GfMatrix4f;
757};
758
759
763GF_API
764bool GfIsClose(GfMatrix4d const &m1, GfMatrix4d const &m2, double tolerance);
765
768GF_API std::ostream& operator<<(std::ostream &, GfMatrix4d const &);
769
770PXR_NAMESPACE_CLOSE_SCOPE
771
772#endif // PXR_BASE_GF_MATRIX4D_H
Declares Gf types.
Stores a 3x3 matrix of double elements.
Definition: matrix3d.h:82
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
GF_API GfMatrix4d & operator*=(const GfMatrix4d &m)
Post-multiplies matrix m into this matrix.
GF_API GfMatrix4d GetTranspose() const
Returns the transpose of the matrix.
GF_API GfMatrix4d & SetTranslateOnly(const GfVec3d &t)
Sets matrix to specify a translation by the vector trans, without clearing the rotation.
bool HasOrthogonalRows3() const
Returns true, if the row vectors of the upper 3x3 matrix form an orthogonal basis.
Definition: matrix4d.h:386
GfVec3d Transform(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:669
friend GfMatrix4d operator*(const GfMatrix4d &m1, double d)
Returns the product of a matrix and a double.
Definition: matrix4d.h:437
GF_API GfMatrix4d & operator-=(const GfMatrix4d &m)
Subtracts matrix m from this matrix.
GF_API GfMatrix4d & SetRotate(const GfMatrix3d &mx)
Sets the matrix to specify a rotation equivalent to mx, and clears the translation.
friend GfMatrix4d operator/(const GfMatrix4d &m1, const GfMatrix4d &m2)
Divides matrix m1 by m2 (that is, m1 * inv(m2)).
Definition: matrix4d.h:487
void SetRow3(int i, const GfVec3d &v)
Sets a row of the matrix from a Vec3.
Definition: matrix4d.h:365
GF_API GfMatrix4d & SetDiagonal(double s)
Sets the matrix to s times the identity matrix.
const double * data() const
Returns const raw access to components of matrix as an array of double values.
Definition: matrix4d.h:279
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:101
GF_API GfMatrix4d & SetRotateOnly(const GfMatrix3d &mx)
Sets the matrix to specify a rotation equivalent to mx, without clearing the translation.
GF_API GfMatrix4d & SetScale(double scaleFactor)
Sets matrix to specify a uniform scaling by scaleFactor.
GF_API GfMatrix3d ExtractRotationMatrix() const
Returns the rotation corresponding to this matrix.
friend size_t hash_value(GfMatrix4d const &m)
Hash.
Definition: matrix4d.h:304
GfVec3d TransformDir(const GfVec3d &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4d.h:693
GfMatrix4d()=default
Default constructor. Leaves the matrix component values undefined.
GF_API GfMatrix4d & SetRotate(const GfRotation &rot)
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
GF_API GfMatrix4d(const GfRotation &rotate, const GfVec3d &translate)
Constructor.
GfVec3d GetRow3(int i) const
Gets a row of the matrix as a Vec3.
Definition: matrix4d.h:372
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:228
GfVec3d ExtractTranslation() const
Returns the translation part of the matrix, defined as the first three elements of the last row.
Definition: matrix4d.h:628
GF_API GfMatrix4d & SetDiagonal(const GfVec4d &)
Sets the matrix to have diagonal (v[0], v[1], v[2], v[3]).
GF_API GfMatrix4d(const std::vector< float > &r0, const std::vector< float > &r1, const std::vector< float > &r2, const std::vector< float > &r3)
Constructor.
GF_API GfMatrix4d RemoveScaleShear() const
Returns the matrix with any scaling or shearing removed, leaving only the rotation and translation.
GfVec4d GetColumn(int i) const
Gets a column of the matrix as a Vec4.
Definition: matrix4d.h:208
GF_API GfMatrix4d & SetRotateOnly(const GfQuatd &rot)
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
GF_API double GetDeterminant() const
Returns the determinant of the matrix.
void SetColumn(int i, const GfVec4d &v)
Sets a column of the matrix from a Vec4.
Definition: matrix4d.h:195
GF_API GfMatrix4d & SetScale(const GfVec3d &scaleFactors)
Sets the matrix to specify a nonuniform scaling in x, y, and z by the factors in vector scaleFactors.
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:296
GfMatrix4d & SetIdentity()
Sets the matrix to the identity matrix.
Definition: matrix4d.h:249
bool operator!=(const GfMatrix4d &m) const
Tests for element-wise matrix inequality.
Definition: matrix4d.h:337
GF_API GfMatrix4d(const std::vector< double > &r0, const std::vector< double > &r1, const std::vector< double > &r2, const std::vector< double > &r3)
Constructor.
GF_API GfMatrix4d(const std::vector< std::vector< double > > &v)
Constructor.
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:215
GF_API bool operator==(const GfMatrix4d &m) const
Tests for element-wise matrix equality.
GF_API double GetHandedness() const
Returns the sign of the determinant of the upper 3x3 matrix, i.e.
GfVec3f TransformDir(const GfVec3f &vec) const
Transforms row vector vec by the matrix, returning the result.
Definition: matrix4d.h:706
GF_API GfMatrix4d & SetTranslate(const GfVec3d &trans)
Sets matrix to specify a translation by the vector trans, and clears the rotation.
double * GetArray()
Returns vector components as an array of double values.
Definition: matrix4d.h:284
friend GfMatrix4d operator+(const GfMatrix4d &m1, const GfMatrix4d &m2)
Adds matrix m2 to m1.
Definition: matrix4d.h:463
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.
GF_API GfMatrix4d & operator+=(const GfMatrix4d &m)
Adds matrix m to this matrix.
double * data()
Returns raw access to components of matrix as an array of double values.
Definition: matrix4d.h:273
void SetRow(int i, const GfVec4d &v)
Sets a row of the matrix from a Vec4.
Definition: matrix4d.h:187
GfMatrix4d(const double m[4][4])
Constructor.
Definition: matrix4d.h:113
GF_API GfMatrix4d(const class GfMatrix4f &m)
This explicit constructor converts a "float" matrix to a "double" matrix.
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.
GfMatrix4d(const GfVec4d &v)
Constructor.
Definition: matrix4d.h:125
GfVec4d GetRow(int i) const
Gets a row of the matrix as a Vec4.
Definition: matrix4d.h:203
GF_API GfMatrix4d(const std::vector< std::vector< float > > &v)
Constructor.
GfMatrix4d(double s)
Constructor.
Definition: matrix4d.h:119
GfVec3d TransformAffine(const GfVec3d &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:717
GF_API bool Orthonormalize(bool issueWarning=true)
Makes the matrix orthonormal in place.
GF_API GfMatrix4d & SetRotate(const GfQuatd &rot)
Sets the matrix to specify a rotation equivalent to rot, and clears the translation.
GfMatrix4d & SetZero()
Sets the matrix to zero.
Definition: matrix4d.h:254
bool IsLeftHanded() const
Returns true if the vectors in the upper 3x3 matrix form a left-handed coordinate system.
Definition: matrix4d.h:424
GF_API GfMatrix4d GetOrthonormalized(bool issueWarning=true) const
Returns an orthonormalized copy of the matrix.
GF_API GfQuatd ExtractRotationQuat() const
Return the rotation corresponding to this matrix as a quaternion.
double GetDeterminant3() const
Returns the determinant of the upper 3x3 matrix.
Definition: matrix4d.h:379
GF_API friend GfMatrix4d operator-(const GfMatrix4d &m)
Returns the unary negation of matrix m.
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.
GfVec3f Transform(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:681
bool IsRightHanded() const
Returns true if the vectors in the upper 3x3 matrix form a right-handed coordinate system.
Definition: matrix4d.h:418
GF_API GfMatrix4d & SetTransform(const GfRotation &rotate, const GfVec3d &translate)
Sets matrix to specify a rotation by rotate and a translation by translate.
GF_API GfMatrix4d & SetRotateOnly(const GfRotation &rot)
Sets the matrix to specify a rotation equivalent to rot, without clearing the translation.
GF_API GfMatrix4d & SetTransform(const GfMatrix3d &rotmx, const GfVec3d &translate)
Sets matrix to specify a rotation by rotmx and a translation by translate.
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:
GF_API GfMatrix4d(const GfMatrix3d &rotmx, const GfVec3d &translate)
Constructor.
GF_API GfMatrix4d & SetLookAt(const GfVec3d &eyePoint, const GfRotation &orientation)
Sets the matrix to specify a viewing matrix from a world-space eyePoint and a world-space rotation th...
GfVec3f TransformAffine(const GfVec3f &vec) const
Transforms the row vector vec by the matrix, returning the result.
Definition: matrix4d.h:728
GF_API GfRotation ExtractRotation() const
Returns the rotation corresponding to this matrix.
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).
const double * GetArray() const
Returns vector components as a const array of double values.
Definition: matrix4d.h:289
Stores a 4x4 matrix of float elements.
Definition: matrix4f.h:88
A class template used by GfMatrixXX to store values.
Definition: matrixData.h:36
T * GetData()
Return a pointer to the start of all the data.
Definition: matrixData.h:50
Basic type: a quaternion, a complex number with a real coefficient and three imaginary coefficients,...
Definition: quatd.h:60
Basic type: 3-space rotation specification.
Definition: rotation.h:54
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
Basic type for a vector of 4 double components.
Definition: vec4d.h:63
Basic type for a vector of 4 float components.
Definition: vec4f.h:63
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Definition: hash.h:492
double GfDot(const GfDualQuatd &dq1, const GfDualQuatd &dq2)
Return the dot (inner) product of two dual quaternions.
Definition: dualQuatd.h:277
Assorted mathematical utility functions.
double GfAbs(double f)
Return abs(f).
Definition: math.h:115
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
#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
Utility functions for GfVec4f and GfVec4d as homogeneous vectors.
GfVec3f GfProject(const GfVec4f &v)
Projects homogeneous v into Euclidean space and returns the result as a Vec3f.
Definition: homogeneous.h:65
Defines useful mathematical limits.
GF_API bool GfIsClose(GfMatrix4d const &m1, GfMatrix4d 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,...
Definition: traits.h:42