HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Matrix3.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_Matrix3_h__
10 #define __HOM_Matrix3_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_ElemPtr.h"
15 #include "HOM_Errors.h"
16 #include "HOM_Module.h"
17 #include "HOM_Vector3.h"
18 #include "HOM_PtrOrNull.h"
19 #include <UT/UT_DMatrix3.h>
20 
21 #include <utility>
22 #include <vector>
23 
24 SWIGOUT(%rename(Matrix3) HOM_Matrix3;)
25 
27 {
28 public:
30  {
32  myMatrix3.zero();
33  }
34  HOM_Matrix3(double diagonal_value)
35  {
37  myMatrix3 = diagonal_value;
38  }
39  HOM_Matrix3(const std::vector<double>&values)
40  {
42  setTo(values);
43  }
44  HOM_Matrix3(const std::vector<std::vector<double> > &values)
45  {
47  setTo(values);
48  }
49 
51  HOM_Matrix3(const HOM_Matrix3 &matrix3)
52  : myMatrix3(matrix3.myMatrix3)
53  { HOM_CONSTRUCT_OBJECT(this) }
55  HOM_Matrix3(const UT_DMatrix3 &matrix3)
56  : myMatrix3(matrix3)
57  { HOM_CONSTRUCT_OBJECT(this) }
58  HOM_Matrix3(const UT_Matrix3 &matrix3)
59  : myMatrix3(matrix3)
60  { HOM_CONSTRUCT_OBJECT(this) }
61 
63  { HOM_DESTRUCT_OBJECT(this) }
64 
66  { return matrix3.myPointer && myMatrix3 == matrix3.myPointer->myMatrix3; }
67 
69  { return !operator==(matrix3); }
70 
71  bool isAlmostEqual(HOM_Matrix3 &matrix3, double tolerance=0.00001);
72 
73  int __hash__();
74  std::string __str__();
76 
77  SWIGOUT(%ignore operator=;)
78  HOM_Matrix3 &operator=(const std::vector<std::vector<double> > &tuple);
80  {
81  myMatrix3 = matrix3.myMatrix3;
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> &tuple);
92  void setTo(const std::vector<std::vector<double> > &tuple);
93 
95  { myMatrix3.identity(); }
96 
97  void setToZero()
98  { myMatrix3.zero(); }
99 
101  { return HOM_Matrix3(myMatrix3 + matrix3.myMatrix3); }
103  { return HOM_Matrix3(myMatrix3 - matrix3.myMatrix3); }
105  { return HOM_Matrix3(myMatrix3 * matrix3.myMatrix3); }
106  HOM_Matrix3 __mul__(double scalar)
107  { return HOM_Matrix3(myMatrix3 * scalar); }
109  { return HOM_Matrix3(matrix3.myMatrix3 * myMatrix3); }
110 
111  HOM_Matrix3 transposed();
112  HOM_Matrix3 inverted();
113  double determinant()
114  { return myMatrix3.determinant(); }
115 
116  SWIGOUT(%kwargs extractRotates;)
117  HOM_Vector3 extractRotates(const char *rotate_order="xyz");
118 
119  SWIGOUT(%kwargs removeScalesAndShears;)
121  removeScalesAndShears(const char *transform_order="srt");
122 
124  { return &myMatrix3; }
125 
126 
127  SWIGOUT(%ignore myMatrix3;)
128  UT_DMatrix3 myMatrix3;
129 
130  // Pickle Support
131  //
132  // By design, pickle doesn't not call __init__() when unpickling. This is a
133  // problem for SWIG though because it requires this in order for the object
134  // to be properly wrapped to the C++ methods. So we need to wrap the
135  // __setstate__() implementation around something that calls __init__()
136  // first. For symmetry, we also wrap __getstate__() as well. So in the
137  // Python implementation, we define __getstate__()/__setstate__() that call
138  // the internal _getstate()/_setstate() C++ methods.
139  std::vector<double> _getstate();
140  void _setstate(std::vector<double>);
141  // NOTE: Be careful with the %pythoncode below which must be indented using
142  // spaces!
143 #ifdef SWIG
144 %extend {
145 %pythoncode {
146  def __getstate__(self):
147  return self._getstate()
148  def __setstate__(self, state):
149  try:
150  self.this
151  except:
152  self.__init__()
153  self._setstate(state)
154 }
155 };
156 #endif
157 };
158 
159 #endif
HOM_Matrix3 preMult(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:108
UT_DMatrix3 myMatrix3
Definition: HOM_Matrix3.h:128
HOM_Matrix3 __mul__(double scalar)
Definition: HOM_Matrix3.h:106
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1303
double determinant()
Definition: HOM_Matrix3.h:113
HOM_Matrix3 & operator=(const HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:79
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:617
void setToIdentity()
Definition: HOM_Matrix3.h:94
HOM_Matrix3(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix3.h:44
#define HOM_API
Definition: HOM_API.h:13
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
HOM_Matrix3 __mul__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:104
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1302
HOM_Matrix3(const HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:51
void * _asVoidPointer()
Definition: HOM_Matrix3.h:123
void setToZero()
Definition: HOM_Matrix3.h:97
bool operator!=(HOM_PtrOrNull< HOM_Matrix3 > matrix3)
Definition: HOM_Matrix3.h:68
HOM_Matrix3(const std::vector< double > &values)
Definition: HOM_Matrix3.h:39
HOM_Matrix3 __add__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:100
HOM_Matrix3(const UT_DMatrix3 &matrix3)
Definition: HOM_Matrix3.h:55
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
HOM_Matrix3(const UT_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:58
HOM_Matrix3 __sub__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:102
bool operator==(HOM_PtrOrNull< HOM_Matrix3 > matrix3)
Definition: HOM_Matrix3.h:65
HOM_Matrix3(double diagonal_value)
Definition: HOM_Matrix3.h:34
Definition: core.h:1131
GLenum GLenum GLsizei void * row
Definition: glad.h:5135
virtual int __hash__()=0
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542