HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Matrix2.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_Matrix2_h__
10 #define __HOM_Matrix2_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_PtrOrNull.h"
18 #include <UT/UT_Matrix2.h>
19 #include <vector>
20 
21 SWIGOUT(%rename(Matrix2) HOM_Matrix2;)
22 
24 {
25 public:
27  {
29  myMatrix2.zero();
30  }
31  HOM_Matrix2(double diagonal_value)
32  {
34  myMatrix2 = diagonal_value;
35  }
36  HOM_Matrix2(const std::vector<double>&values)
37  {
39  setTo(values);
40  }
41  HOM_Matrix2(const std::vector<std::vector<double> > &values)
42  {
44  setTo(values);
45  }
46 
48  HOM_Matrix2(const HOM_Matrix2 &matrix2)
49  : myMatrix2(matrix2.myMatrix2)
50  { HOM_CONSTRUCT_OBJECT(this) }
52  HOM_Matrix2(const UT_DMatrix2 &matrix2)
53  : myMatrix2(matrix2)
54  { HOM_CONSTRUCT_OBJECT(this) }
55  HOM_Matrix2(const UT_Matrix2 &matrix2)
56  : myMatrix2(matrix2)
57  { HOM_CONSTRUCT_OBJECT(this) }
58 
60  { HOM_DESTRUCT_OBJECT(this) }
61 
63  { return matrix2.myPointer && myMatrix2 == matrix2.myPointer->myMatrix2; }
64 
66  { return !operator==(matrix2); }
67 
68  bool isAlmostEqual(HOM_Matrix2 &matrix2, double tolerance=0.00001);
69 
70  int __hash__();
71  std::string __str__();
73 
74  SWIGOUT(%ignore operator=;)
75  HOM_Matrix2 &operator=(const std::vector<std::vector<double> > &tuple);
77  {
78  myMatrix2 = matrix2.myMatrix2;
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> &tuple);
89  void setTo(const std::vector<std::vector<double> > &tuple);
90 
92  { myMatrix2.identity(); }
93 
94  void setToZero()
95  { myMatrix2.zero(); }
96 
98  { return HOM_Matrix2(myMatrix2 + matrix2.myMatrix2); }
100  { return HOM_Matrix2(myMatrix2 - matrix2.myMatrix2); }
102  { return HOM_Matrix2(myMatrix2 * matrix2.myMatrix2); }
103  HOM_Matrix2 __mul__(double scalar)
104  { return HOM_Matrix2(myMatrix2 * scalar); }
106  { return HOM_Matrix2(matrix2.myMatrix2 * myMatrix2); }
107 
108  HOM_Matrix2 transposed();
109  HOM_Matrix2 inverted();
110  double determinant()
111  { return myMatrix2.determinant(); }
112 
114  { return &myMatrix2; }
115 
116 
117  SWIGOUT(%ignore myMatrix2;)
118  UT_DMatrix2 myMatrix2;
119 
120  // Pickle Support
121  //
122  // By design, pickle doesn't not call __init__() when unpickling. This is a
123  // problem for SWIG though because it requires this in order for the object
124  // to be properly wrapped to the C++ methods. So we need to wrap the
125  // __setstate__() implementation around something that calls __init__()
126  // first. For symmetry, we also wrap __getstate__() as well. So in the
127  // Python implementation, we define __getstate__()/__setstate__() that call
128  // the internal _getstate()/_setstate() C++ methods.
129  std::vector<double> _getstate();
130  void _setstate(std::vector<double>);
131  // NOTE: Be careful with the %pythoncode below which must be indented using
132  // spaces!
133 #ifdef SWIG
134 %extend {
135 %pythoncode {
136  def __getstate__(self):
137  return self._getstate()
138  def __setstate__(self, state):
139  try:
140  self.this
141  except:
142  self.__init__()
143  self._setstate(state)
144 }
145 };
146 #endif
147 };
148 
149 #endif
HOM_Matrix2(const HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:48
HOM_Matrix2 __mul__(double scalar)
Definition: HOM_Matrix2.h:103
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1303
HOM_Matrix2(const std::vector< double > &values)
Definition: HOM_Matrix2.h:36
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HOM_Matrix2 __sub__(HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:99
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
void setToIdentity()
Definition: HOM_Matrix2.h:91
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
HOM_Matrix2 & operator=(const HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:76
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:617
HOM_Matrix2 __add__(HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:97
void * _asVoidPointer()
Definition: HOM_Matrix2.h:113
HOM_Matrix2(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix2.h:41
void setToZero()
Definition: HOM_Matrix2.h:94
HOM_Matrix2(const UT_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:55
#define HOM_API
Definition: HOM_API.h:13
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
bool operator==(HOM_PtrOrNull< HOM_Matrix2 > matrix2)
Definition: HOM_Matrix2.h:62
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1302
HOM_Matrix2(const UT_DMatrix2 &matrix2)
Definition: HOM_Matrix2.h:52
double determinant()
Definition: HOM_Matrix2.h:110
HOM_Matrix2 preMult(HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:105
bool operator!=(HOM_PtrOrNull< HOM_Matrix2 > matrix2)
Definition: HOM_Matrix2.h:65
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
HOM_Matrix2(double diagonal_value)
Definition: HOM_Matrix2.h:31
UT_DMatrix2 myMatrix2
Definition: HOM_Matrix2.h:118
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
HOM_Matrix2 __mul__(HOM_Matrix2 &matrix2)
Definition: HOM_Matrix2.h:101