HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  HOM_Matrix4(const UT_Matrix4 &matrix4)
59  : myMatrix4(matrix4)
60  { HOM_CONSTRUCT_OBJECT(this) }
61 
63  { HOM_DESTRUCT_OBJECT(this) }
64 
66  { return matrix4.myPointer && myMatrix4 == matrix4.myPointer->myMatrix4; }
67 
69  { return !operator==(matrix4); }
70 
71  bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001);
72 
73  int __hash__();
76 
77  SWIGOUT(%ignore operator=;)
78  HOM_Matrix4 &operator=(const std::vector<std::vector<double> > &sequence);
80  {
81  myMatrix4 = matrix4.myMatrix4;
82  return *this;
83  }
84 
85  double at(int row, int col);
86 
87  std::vector<double> asTuple();
88  std::vector<std::vector<double> > asTupleOfTuples();
89 
90  void setAt(int row, int col, double value);
91  void setTo(const std::vector<double> &sequence);
92  void setTo(const std::vector<std::vector<double> > &sequence);
93 
95  { myMatrix4.identity(); }
96 
97  void setToZero()
98  { myMatrix4.zero(); }
99 
101  { return HOM_Matrix4(myMatrix4 + matrix4.myMatrix4); }
103  { return HOM_Matrix4(myMatrix4 - matrix4.myMatrix4); }
105  { return HOM_Matrix4(myMatrix4 * matrix4.myMatrix4); }
106  HOM_Matrix4 __mul__(double scalar)
107  { return HOM_Matrix4(myMatrix4 * scalar); }
109  { return HOM_Matrix4(matrix4.myMatrix4 * myMatrix4); }
110 
111  HOM_Matrix4 transposed();
112  HOM_Matrix4 inverted();
113  double determinant()
114  { return myMatrix4.determinant(); }
115 
116  SWIGOUT(%kwargs explode;)
117  std::map<std::string, HOM_Vector3> explode(
118  const char *transform_order="srt",
119  const char *rotate_order="xyz",
120  const HOM_Vector3 &pivot=HOM_Vector3(),
121  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
122 
123  SWIGOUT(%kwargs extractTranslates;)
124  HOM_Vector3 extractTranslates(const char *transform_order="srt",
125  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
126 
127  SWIGOUT(%kwargs extractRotates;)
128  HOM_Vector3 extractRotates(
129  const char *transform_order="srt",
130  const char *rotate_order="xyz",
131  const HOM_Vector3 &pivot=HOM_Vector3(),
132  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
133 
134  SWIGOUT(%kwargs extractScales;)
135  HOM_Vector3 extractScales(
136  const char *transform_order="srt",
137  const HOM_Vector3 &pivot=HOM_Vector3(),
138  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
139 
140  SWIGOUT(%kwargs extractShears;)
141  HOM_Vector3 extractShears(
142  const char *transform_order="srt",
143  const HOM_Vector3 &pivot=HOM_Vector3(),
144  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
145 
146  SWIGOUT(%newobject extractRotationMatrix3;)
147  HOM_Matrix3 *extractRotationMatrix3();
148 
150  { return &myMatrix4; }
151 
152 
153  SWIGOUT(%ignore myMatrix4;)
154  UT_DMatrix4 myMatrix4;
155 };
156 
157 #endif
UT_DMatrix3 myMatrix3
Definition: HOM_Matrix3.h:117
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1056
HOM_Matrix4 & operator=(const HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:79
virtual int __hash__()=0
void setToZero()
Definition: HOM_Matrix4.h:97
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HOM_Matrix4 __mul__(double scalar)
Definition: HOM_Matrix4.h:106
HOM_Matrix4(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix4.h:48
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
void setToIdentity()
Definition: HOM_Matrix4.h:94
void * _asVoidPointer()
Definition: HOM_Matrix4.h:149
UT_DMatrix4 myMatrix4
Definition: HOM_Matrix4.h:154
HOM_Matrix4(const UT_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:58
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:344
HOM_Matrix4(const std::vector< double > &values)
Definition: HOM_Matrix4.h:38
HOM_Matrix4 preMult(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:108
#define HOM_API
Definition: HOM_API.h:13
HOM_Matrix4 __add__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:100
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1055
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:65
GLsizei const GLfloat * value
Definition: glcorearb.h:823
HOM_Matrix4 __mul__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:104
virtual std::string __str__()=0
GA_API const UT_StringHolder pivot
double determinant()
Definition: HOM_Matrix4.h:113
bool operator!=(HOM_PtrOrNull< HOM_Matrix4 > matrix4)
Definition: HOM_Matrix4.h:68
HOM_Matrix4 __sub__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:102
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:590
HOM_Matrix4(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix4.h:43