HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Quaternion.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_Quaternion_h__
10 #define __HOM_Quaternion_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_Quaternion.h>
19 #include <vector>
20 #include <stdexcept>
21 
22 class HOM_Matrix3;
23 class HOM_Matrix4;
24 
25 SWIGOUT(%rename(Quaternion) HOM_Quaternion;)
26 
28 {
29 public:
31  : myQuaternion(0.0, 0.0, 0.0, 1.0)
32  { HOM_CONSTRUCT_OBJECT(this) }
33 
34  HOM_Quaternion(const std::vector<double> &sequence)
35  {
37  setTo(sequence);
38  }
39 
40  HOM_Quaternion(double x, double y, double z, double w)
41  : myQuaternion(x, y, z, w)
42  { HOM_CONSTRUCT_OBJECT(this) }
43 
44  HOM_Quaternion(double angle_in_deg, const std::vector<double> &axis)
45  {
46  setToAngleAxis(angle_in_deg, axis);
48  }
49 
50  HOM_Quaternion(HOM_Matrix3 &matrix3);
51  HOM_Quaternion(HOM_Matrix4 &matrix4);
52 
53  SWIGOUT(%ignore HOM_Quaternion(const HOM_Quaternion&);)
54  HOM_Quaternion(const HOM_Quaternion &quaternion)
55  : myQuaternion(quaternion.myQuaternion)
56  { HOM_CONSTRUCT_OBJECT(this) }
57 
58  SWIGOUT(%ignore HOM_Quaternion(const UT_QuaternionD&);)
59  HOM_Quaternion(const UT_QuaternionD &quaternion)
60  : myQuaternion(quaternion)
61  { HOM_CONSTRUCT_OBJECT(this) }
62 
64  { HOM_DESTRUCT_OBJECT(this) }
65 
67  { return quaternion.myPointer &&
68  myQuaternion == quaternion.myPointer->myQuaternion; }
69 
71  { return !operator==(quaternion); }
72 
73  bool isAlmostEqual(HOM_Quaternion &quaternion, double tolerance=0.00001);
74 
75  // This method is deprecated.
76  bool almostEqual(HOM_Quaternion &quaternion, double tolerance=0.00001)
77  { return isAlmostEqual(quaternion, tolerance); }
78 
79  int __hash__();
82 
83  double __getitem__(int index);
84  void __setitem__(int index, double value);
85  int __len__()
86  { return 4; }
87 
88  void setTo(const std::vector<double> &tuple);
89 
90  void setToRotationMatrix(HOM_Matrix3 &matrix3);
91  void setToRotationMatrix(HOM_Matrix4 &matrix4);
92 
93  void setToAngleAxis(double angle_in_deg, const std::vector<double> &axis);
94 
95  void setToVectors(const HOM_Vector3 &v1, const HOM_Vector3 &v2);
96 
97  SWIGOUT(%kwargs setToEulerRotates;)
98  void setToEulerRotates(
99  const std::vector<double> &angles_in_deg,
100  const char *rotate_order="xyz");
101 
102  SWIGOUT(%ignore operator=;)
103  HOM_Quaternion &operator=(const HOM_Quaternion& quaternion)
104  {
105  myQuaternion = quaternion.myQuaternion;
106  return *this;
107  }
108 
109  HOM_Quaternion conjugate();
110  HOM_Quaternion inverse();
111  double dot(HOM_Quaternion &quaternion)
112  { return ::dot(myQuaternion, quaternion.myQuaternion); }
113 
115  { return HOM_Quaternion(myQuaternion + quaternion.myQuaternion); }
117  { return HOM_Quaternion(myQuaternion - quaternion.myQuaternion); }
118  HOM_Quaternion __mul__(double scalar)
119  { return HOM_Quaternion(myQuaternion * scalar); }
121 
122  HOM_Quaternion slerp(HOM_Quaternion &other, double fraction);
123 
124 
126 
127  double length()
128  { return myQuaternion.length(); }
129 
130 
131  SWIGOUT(%newobject extractRotationMatrix3;)
133 
134  std::pair<double, HOM_ElemPtr<HOM_Vector3> > extractAngleAxis();
135 
136  HOM_Vector3 extractEulerRotates(const char *rotate_order="xyz");
137 
139 
141  { return &myQuaternion; }
142 
143 
144  SWIGOUT(%ignore myQuaternion;)
145  UT_QuaternionD myQuaternion;
146 };
147 
148 #endif
bool almostEqual(HOM_Quaternion &quaternion, double tolerance=0.00001)
bool operator==(HOM_PtrOrNull< HOM_Quaternion > quaternion)
HOM_Quaternion(double x, double y, double z, double w)
double dot(HOM_Quaternion &quaternion)
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1238
HOM_Quaternion __sub__(HOM_Quaternion &quaternion)
OIIO_API bool rename(string_view from, string_view to, std::string &err)
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
HOM_Quaternion(const HOM_Quaternion &quaternion)
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:353
HOM_Quaternion(double angle_in_deg, const std::vector< double > &axis)
HOM_Quaternion(const std::vector< double > &sequence)
void * _asVoidPointer()
GLint GLenum GLint x
Definition: glcorearb.h:408
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
std::string __str__()
Quat< T > slerp(const Quat< T > &q1, const Quat< T > &q2, T t)
Definition: ImathQuat.h:495
#define HOM_API
Definition: HOM_API.h:13
GLint GLenum GLboolean normalized
Definition: glcorearb.h:871
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:817
const GLdouble * v
Definition: glcorearb.h:836
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
Definition: CE_Vector.h:130
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1237
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
HOM_Quaternion __add__(HOM_Quaternion &quaternion)
int __hash__()
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
HOM_Matrix3 * extractRotationMatrix3()
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
HOM_Quaternion __mul__(double scalar)
void setTo(const std::vector< double > &sequence)
HOM_Matrix4 __mul__(HOM_Matrix4 &matrix4)
Definition: HOM_Matrix4.h:108
bool isAlmostEqual(HOM_Matrix4 &matrix4, double tolerance=0.00001)
HOM_Quaternion(const UT_QuaternionD &quaternion)
GLuint index
Definition: glcorearb.h:785
GLsizei const GLfloat * value
Definition: glcorearb.h:823
GLfloat GLfloat v1
Definition: glcorearb.h:816
UT_QuaternionD myQuaternion
bool operator!=(HOM_PtrOrNull< HOM_Quaternion > quaternion)
GLint y
Definition: glcorearb.h:102
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:556