HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HOM_Matrix4.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  */
8 
9 #ifndef __HOM_Matrix4_h__
10 #define __HOM_Matrix4_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_Errors.h"
15 #include "HOM_Module.h"
16 #include "HOM_Vector3.h"
17 #include "HOM_Matrix3.h"
18 #include "HOM_PtrOrNull.h"
19 #include <UT/UT_DMatrix4.h>
20 #include <vector>
21 #include <stdexcept>
22 
23 SWIGOUT(%rename(Matrix4) HOM_Matrix4;)
24 
26 {
27 public:
29  {
31  myMatrix4.zero();
32  }
33  HOM_Matrix4(double diagonal_value)
34  {
36  myMatrix4 = diagonal_value;
37  }
38  HOM_Matrix4(const std::vector<double> &values)
39  {
41  setTo(values);
42  }
43  HOM_Matrix4(const std::vector<std::vector<double> > &values)
44  {
46  setTo(values);
47  }
49  {
51  myMatrix4 = matrix3.myMatrix3;
52  }
53 
54  SWIGOUT(%ignore HOM_Matrix4(const UT_DMatrix4&);)
55  HOM_Matrix4(const UT_DMatrix4 &matrix4)
56  : myMatrix4(matrix4)
57  { HOM_CONSTRUCT_OBJECT(this) }
58 
60  { HOM_DESTRUCT_OBJECT(this) }
61 
63  { return matrix4.myPointer && myMatrix4 == matrix4.myPointer->myMatrix4; }
64 
66  { return !operator==(matrix4); }
67 
68  bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001);
69 
70  int __hash__();
71  std::string __str__();
73 
74  SWIGOUT(%ignore operator=;)
75  HOM_Matrix4 &operator=(const std::vector<std::vector<double> > &sequence);
77  {
78  myMatrix4 = matrix4.myMatrix4;
79  return *this;
80  }
81 
82  double at(int row, int col);
83 
84  std::vector<double> asTuple();
85  std::vector<std::vector<double> > asTupleOfTuples();
86 
87  void setAt(int row, int col, double value);
88  void setTo(const std::vector<double> &sequence);
89  void setTo(const std::vector<std::vector<double> > &sequence);
90 
92  { myMatrix4.identity(); }
93 
94  void setToZero()
95  { myMatrix4.zero(); }
96 
98  { return HOM_Matrix4(myMatrix4 + matrix4.myMatrix4); }
100  { return HOM_Matrix4(myMatrix4 - matrix4.myMatrix4); }
102  { return HOM_Matrix4(myMatrix4 * matrix4.myMatrix4); }
103  HOM_Matrix4 __mul__(double scalar)
104  { return HOM_Matrix4(myMatrix4 * scalar); }
106  { return HOM_Matrix4(matrix4.myMatrix4 * myMatrix4); }
107 
108  HOM_Matrix4 transposed();
109  HOM_Matrix4 inverted();
110  double determinant()
111  { return myMatrix4.determinant(); }
112 
113  SWIGOUT(%kwargs explode;)
114  std::map<std::string, HOM_Vector3> explode(
115  const char *transform_order="srt",
116  const char *rotate_order="xyz",
117  const HOM_Vector3 &pivot=HOM_Vector3(),
118  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
119 
120  SWIGOUT(%kwargs extractTranslates;)
121  HOM_Vector3 extractTranslates(const char *transform_order="srt",
122  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
123 
124  SWIGOUT(%kwargs extractRotates;)
125  HOM_Vector3 extractRotates(
126  const char *transform_order="srt",
127  const char *rotate_order="xyz",
128  const HOM_Vector3 &pivot=HOM_Vector3(),
129  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
130 
131  SWIGOUT(%kwargs extractScales;)
132  HOM_Vector3 extractScales(
133  const char *transform_order="srt",
134  const HOM_Vector3 &pivot=HOM_Vector3(),
135  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
136 
137  SWIGOUT(%kwargs extractShears;)
138  HOM_Vector3 extractShears(
139  const char *transform_order="srt",
140  const HOM_Vector3 &pivot=HOM_Vector3(),
141  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
142 
143  SWIGOUT(%newobject extractRotationMatrix3;)
144  HOM_Matrix3 *extractRotationMatrix3();
145 
147  { return &myMatrix4; }
148 
149 
150  SWIGOUT(%ignore myMatrix4;)
151  UT_DMatrix4 myMatrix4;
152 };
153 
154 #endif
UT_DMatrix3 myMatrix3
Definition: HOM_Matrix3.h:114
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:973
HOM_Matrix4 & operator=(const HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:76
void setToZero()
Definition: HOM_Matrix4.h:94
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HOM_Matrix4 __mul__(double scalar)
Definition: HOM_Matrix4.h:103
HOM_Matrix4(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix4.h:48
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
void setToIdentity()
Definition: HOM_Matrix4.h:91
void * _asVoidPointer()
Definition: HOM_Matrix4.h:146
UT_DMatrix4 myMatrix4
Definition: HOM_Matrix4.h:151
HOM_Matrix4(const std::vector< double > &values)
Definition: HOM_Matrix4.h:38
HOM_Matrix4 preMult(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:105
#define HOM_API
Definition: HOM_API.h:13
HOM_Matrix4 __add__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:97
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:972
HOM_Matrix4(double diagonal_value)
Definition: HOM_Matrix4.h:33
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1601
png_bytepp row
Definition: png.h:1836
bool operator==(HOM_PtrOrNull< HOM_Matrix4 > matrix4)
Definition: HOM_Matrix4.h:62
GLsizei const GLfloat * value
Definition: glcorearb.h:823
HOM_Matrix4 __mul__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:101
virtual std::string __repr__()=0
virtual int __hash__()=0
GA_API const UT_StringHolder pivot
double determinant()
Definition: HOM_Matrix4.h:110
bool operator!=(HOM_PtrOrNull< HOM_Matrix4 > matrix4)
Definition: HOM_Matrix4.h:65
HOM_Matrix4 __sub__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:99
HOM_Matrix4(const UT_DMatrix4 &matrix4)
Definition: HOM_Matrix4.h:55
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:596
HOM_Matrix4(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix4.h:43