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 class HOM_Matrix4;
25 
27 
29 {
30 public:
32  {
34  myMatrix3.zero();
35  }
36  HOM_Matrix3(double diagonal_value)
37  {
39  myMatrix3 = diagonal_value;
40  }
41  HOM_Matrix3(const std::vector<double>&values)
42  {
44  setTo(values);
45  }
46  HOM_Matrix3(const std::vector<std::vector<double> > &values)
47  {
49  setTo(values);
50  }
51 
52  HOM_Matrix3(const HOM_Matrix4 &matrix4);
53 
55  HOM_Matrix3(const HOM_Matrix3 &matrix3)
56  : myMatrix3(matrix3.myMatrix3)
57  { HOM_CONSTRUCT_OBJECT(this) }
59  HOM_Matrix3(const UT_DMatrix3 &matrix3)
60  : myMatrix3(matrix3)
61  { HOM_CONSTRUCT_OBJECT(this) }
62  HOM_Matrix3(const UT_Matrix3 &matrix3)
63  : myMatrix3(matrix3)
64  { HOM_CONSTRUCT_OBJECT(this) }
65 
67  { HOM_DESTRUCT_OBJECT(this) }
68 
70  { return matrix3.myPointer && myMatrix3 == matrix3.myPointer->myMatrix3; }
71 
73  { return !operator==(matrix3); }
74 
75  bool isAlmostEqual(HOM_Matrix3 &matrix3, double tolerance=0.00001);
76 
77  int __hash__();
78  std::string __str__();
79  std::string __repr__();
80 
81  SWIGOUT(%ignore operator=;)
82  HOM_Matrix3 &operator=(const std::vector<std::vector<double> > &tuple);
83 
85  {
86  myMatrix3 = matrix3.myMatrix3;
87  return *this;
88  }
89  HOM_Matrix3 &operator=(const HOM_Matrix4& matrix4);
90 
91  double at(int row, int col);
92 
93  std::vector<double> asTuple();
94  std::vector<std::vector<double> > asTupleOfTuples();
95 
96  void setAt(int row, int col, double value);
97  void setTo(const std::vector<double> &tuple);
98  void setTo(const std::vector<std::vector<double> > &tuple);
99 
101  { myMatrix3.identity(); }
102 
103  void setToZero()
104  { myMatrix3.zero(); }
105 
107  { return HOM_Matrix3(myMatrix3 + matrix3.myMatrix3); }
109  { return HOM_Matrix3(myMatrix3 - matrix3.myMatrix3); }
111  { return HOM_Matrix3(myMatrix3 * matrix3.myMatrix3); }
112  HOM_Matrix3 __mul__(double scalar)
113  { return HOM_Matrix3(myMatrix3 * scalar); }
115  { return HOM_Matrix3(matrix3.myMatrix3 * myMatrix3); }
116 
119  double determinant()
120  { return myMatrix3.determinant(); }
121 
122  SWIGOUT(%kwargs extractRotates;)
123  HOM_Vector3 extractRotates(const char *rotate_order="xyz");
124 
125  SWIGOUT(%kwargs removeScalesAndShears;)
127  removeScalesAndShears(const char *transform_order="srt");
128 
130  { return &myMatrix3; }
131 
132 
133  SWIGOUT(%ignore myMatrix3;)
134  UT_DMatrix3 myMatrix3;
135 
136  // Pickle Support
137  //
138  // By design, pickle doesn't not call __init__() when unpickling. This is a
139  // problem for SWIG though because it requires this in order for the object
140  // to be properly wrapped to the C++ methods. So we need to wrap the
141  // __setstate__() implementation around something that calls __init__()
142  // first. For symmetry, we also wrap __getstate__() as well. So in the
143  // Python implementation, we define __getstate__()/__setstate__() that call
144  // the internal _getstate()/_setstate() C++ methods.
145  std::vector<double> _getstate();
146  void _setstate(std::vector<double>);
147  // NOTE: Be careful with the %pythoncode below which must be indented using
148  // spaces!
149 #ifdef SWIG
150 %extend {
151 %pythoncode {
152  def __getstate__(self):
153  return self._getstate()
154  def __setstate__(self, state):
155  try:
156  self.this
157  except:
158  self.__init__()
159  self._setstate(state)
160 }
161 };
162 #endif
163 };
164 
165 #endif
HOM_Vector3 extractRotates(const char *transform_order="srt", const char *rotate_order="xyz", const HOM_Vector3 &pivot=HOM_Vector3(), const HOM_Vector3 &pivot_rotate=HOM_Vector3())
HOM_Matrix3 preMult(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:114
UT_DMatrix3 myMatrix3
Definition: HOM_Matrix3.h:134
HOM_Matrix3 __mul__(double scalar)
Definition: HOM_Matrix3.h:112
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1343
double determinant()
Definition: HOM_Matrix3.h:119
HOM_Matrix3 & operator=(const HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:84
GLsizei const GLfloat * value
Definition: glcorearb.h:824
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:312
**But if you need a or simply need to know when the task has note that the like this
Definition: thread.h:626
void setToIdentity()
Definition: HOM_Matrix3.h:100
HOM_Matrix3(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix3.h:46
HOM_Matrix4 transposed()
std::string __str__()
void _setstate(std::vector< double >)
#define HOM_API
Definition: HOM_API.h:13
std::vector< double > _getstate()
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
HOM_Matrix3 __mul__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:110
double at(int row, int col)
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1342
int __hash__()
UT_Matrix3T< Float > Matrix3
Definition: APEX_Include.h:67
HOM_Matrix3(const HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:55
void * _asVoidPointer()
Definition: HOM_Matrix3.h:129
void setAt(int row, int col, double value)
void setToZero()
Definition: HOM_Matrix3.h:103
bool operator!=(HOM_PtrOrNull< HOM_Matrix3 > matrix3)
Definition: HOM_Matrix3.h:72
HOM_Matrix3(const std::vector< double > &values)
Definition: HOM_Matrix3.h:41
void setTo(const std::vector< double > &sequence)
HOM_Matrix3 __add__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:106
HOM_Matrix3(const UT_DMatrix3 &matrix3)
Definition: HOM_Matrix3.h:59
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001)
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
std::vector< std::vector< double > > asTupleOfTuples()
LeafData & operator=(const LeafData &)=delete
HOM_Matrix3(const UT_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:62
HOM_Matrix3 __sub__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:108
bool operator==(HOM_PtrOrNull< HOM_Matrix3 > matrix3)
Definition: HOM_Matrix3.h:69
std::vector< double > asTuple()
HOM_Matrix3(double diagonal_value)
Definition: HOM_Matrix3.h:36
GLenum GLenum GLsizei void * row
Definition: glad.h:5135
state
Definition: core.h:2289
HOM_Matrix4 inverted()
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542