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 
55  HOM_Matrix4(const HOM_Matrix4 &matrix4)
56  : myMatrix4(matrix4.myMatrix4)
57  { HOM_CONSTRUCT_OBJECT(this) }
59  HOM_Matrix4(const UT_DMatrix4 &matrix4)
60  : myMatrix4(matrix4)
61  { HOM_CONSTRUCT_OBJECT(this) }
62  HOM_Matrix4(const UT_Matrix4 &matrix4)
63  : myMatrix4(matrix4)
64  { HOM_CONSTRUCT_OBJECT(this) }
65 
67  { HOM_DESTRUCT_OBJECT(this) }
68 
70  { return matrix4.myPointer && myMatrix4 == matrix4.myPointer->myMatrix4; }
71 
73  { return !operator==(matrix4); }
74 
75  bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001);
76 
77  int __hash__();
78  std::string __str__();
80 
81  SWIGOUT(%ignore operator=;)
82  HOM_Matrix4 &operator=(const std::vector<std::vector<double> > &sequence);
84  {
85  myMatrix4 = matrix4.myMatrix4;
86  return *this;
87  }
88 
89  double at(int row, int col);
90 
91  std::vector<double> asTuple();
92  std::vector<std::vector<double> > asTupleOfTuples();
93 
94  void setAt(int row, int col, double value);
95  void setTo(const std::vector<double> &sequence);
96  void setTo(const std::vector<std::vector<double> > &sequence);
97 
99  { myMatrix4.identity(); }
100 
101  void setToZero()
102  { myMatrix4.zero(); }
103 
105  { return HOM_Matrix4(myMatrix4 + matrix4.myMatrix4); }
107  { return HOM_Matrix4(myMatrix4 - matrix4.myMatrix4); }
109  { return HOM_Matrix4(myMatrix4 * matrix4.myMatrix4); }
110  HOM_Matrix4 __mul__(double scalar)
111  { return HOM_Matrix4(myMatrix4 * scalar); }
113  { return HOM_Matrix4(matrix4.myMatrix4 * myMatrix4); }
114 
115  HOM_Matrix4 transposed();
116  HOM_Matrix4 inverted();
117  double determinant()
118  { return myMatrix4.determinant(); }
119 
120  SWIGOUT(%kwargs explode;)
121  std::map<std::string, HOM_Vector3> explode(
122  const char *transform_order="srt",
123  const char *rotate_order="xyz",
124  const HOM_Vector3 &pivot=HOM_Vector3(),
125  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
126 
127  SWIGOUT(%kwargs extractTranslates;)
128  HOM_Vector3 extractTranslates(const char *transform_order="srt",
129  const HOM_Vector3 &pivot_rotate=HOM_Vector3(),
130  const HOM_Vector3 &pivot=HOM_Vector3());
131 
132  SWIGOUT(%kwargs extractRotates;)
133  HOM_Vector3 extractRotates(
134  const char *transform_order="srt",
135  const char *rotate_order="xyz",
136  const HOM_Vector3 &pivot=HOM_Vector3(),
137  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
138 
139  SWIGOUT(%kwargs extractScales;)
140  HOM_Vector3 extractScales(
141  const char *transform_order="srt",
142  const HOM_Vector3 &pivot=HOM_Vector3(),
143  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
144 
145  SWIGOUT(%kwargs extractShears;)
146  HOM_Vector3 extractShears(
147  const char *transform_order="srt",
148  const HOM_Vector3 &pivot=HOM_Vector3(),
149  const HOM_Vector3 &pivot_rotate=HOM_Vector3());
150 
151  SWIGOUT(%newobject extractRotationMatrix3;)
152  HOM_Matrix3 *extractRotationMatrix3();
153 
154 
155  void setToPerspective(
156  double zoom,
157  double image_aspect=1,
158  double pixel_aspect=1,
159  double clip_near=0, double clip_far=1,
160  double window_xmin=0, double window_xmax=1,
161  double window_ymin=0, double window_ymax=1);
162 
163  void setToOrthographic(
164  double zoom,
165  double orthowidth=1,
166  double image_aspect=1,
167  double pixel_aspect=1,
168  double clip_near=0, double clip_far=1,
169  double window_xmin=0, double window_xmax=1,
170  double window_ymin=0, double window_ymax=1);
171 
172 
174  { return &myMatrix4; }
175 
176 
177  SWIGOUT(%ignore myMatrix4;)
178  UT_DMatrix4 myMatrix4;
179 };
180 
181 #endif
UT_DMatrix3 myMatrix3
Definition: HOM_Matrix3.h:128
HOM_Matrix4(const HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:55
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1291
HOM_Matrix4 & operator=(const HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:83
void setToZero()
Definition: HOM_Matrix4.h:101
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
HOM_Matrix4 __mul__(double scalar)
Definition: HOM_Matrix4.h:110
HOM_Matrix4(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix4.h:48
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
void setToIdentity()
Definition: HOM_Matrix4.h:98
void * _asVoidPointer()
Definition: HOM_Matrix4.h:173
UT_DMatrix4 myMatrix4
Definition: HOM_Matrix4.h:178
HOM_Matrix4(const UT_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:62
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:352
HOM_Matrix4(const std::vector< double > &values)
Definition: HOM_Matrix4.h:38
HOM_Matrix4 preMult(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:112
#define HOM_API
Definition: HOM_API.h:13
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
HOM_Matrix4 __add__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:104
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1290
HOM_Matrix4(double diagonal_value)
Definition: HOM_Matrix4.h:33
bool operator==(HOM_PtrOrNull< HOM_Matrix4 > matrix4)
Definition: HOM_Matrix4.h:69
HOM_Matrix4 __mul__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:108
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
GA_API const UT_StringHolder pivot
double determinant()
Definition: HOM_Matrix4.h:117
Definition: core.h:1131
GLenum GLenum GLsizei void * row
Definition: glad.h:5135
bool operator!=(HOM_PtrOrNull< HOM_Matrix4 > matrix4)
Definition: HOM_Matrix4.h:72
HOM_Matrix4 __sub__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:106
virtual int __hash__()=0
HOM_Matrix4(const UT_DMatrix4 &matrix4)
Definition: HOM_Matrix4.h:59
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HOM_Matrix4(const std::vector< std::vector< double > > &values)
Definition: HOM_Matrix4.h:43