HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Vector3.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_Vector3_h__
10 #define __HOM_Vector3_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_PtrOrNull.h"
17 #include <UT/UT_Vector3.h>
18 #include <vector>
19 #include <stdexcept>
20 class HOM_Matrix4;
21 class HOM_Vector4;
22 class HOM_Matrix3;
23 
24 SWIGOUT(%rename(Vector3) HOM_Vector3;)
25 
27 {
28 public:
30  : myVector3(0.0, 0.0, 0.0)
31  { HOM_CONSTRUCT_OBJECT(this) }
32 
33  HOM_Vector3(double x, double y, double z)
34  : myVector3(x, y, z)
35  { HOM_CONSTRUCT_OBJECT(this) }
36 
37  SWIGOUT(%ignore HOM_Vector3(const UT_Vector3D&);)
38  HOM_Vector3(const UT_Vector3D &vector3)
39  : myVector3(vector3)
40  { HOM_CONSTRUCT_OBJECT(this) }
41 
42  SWIGOUT(%ignore HOM_Vector3(const UT_Vector3F&);)
43  HOM_Vector3(const UT_Vector3F &vector3)
44  : myVector3(vector3)
45  { HOM_CONSTRUCT_OBJECT(this) }
46 
47  HOM_Vector3(const std::vector<double> &sequence)
48  {
50  setTo(sequence);
51  }
52 
53  HOM_Vector3(HOM_Vector4 &vector4);
54 
56  { HOM_DESTRUCT_OBJECT(this) }
57 
59  { return vector3.myPointer && myVector3 == vector3.myPointer->myVector3; }
60 
62  { return !operator==(vector3); }
63 
64  bool isAlmostEqual(HOM_Vector3 &vector3, double tolerance=0.00001);
65 
66  // This method is deprecated.
67  bool almostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
68  { return isAlmostEqual(vector3, tolerance); }
69 
70  int __hash__();
73 
74  double __getitem__(int index);
75  void __setitem__(int index, double value);
76  int __len__()
77  { return 3; }
78 
79  // operator[] exists only to make this class easier to use from C++,
80  // and isn't wrapped by swig.
81  SWIGOUT(%ignore operator[];)
82  double &operator[](int index);
83 
84  void setTo(const std::vector<double> &sequence);
85 
86  SWIGOUT(%ignore operator=;)
87  HOM_Vector3 &operator=(const HOM_Vector3& vector3)
88  {
89  myVector3 = vector3.myVector3;
90  return *this;
91  }
92 
94  { return HOM_Vector3(myVector3 + vector3.myVector3); }
96  { return HOM_Vector3(myVector3 - vector3.myVector3); }
98  { return HOM_Vector3(-myVector3); }
99  HOM_Vector3 __mul__(double scalar)
100  { return HOM_Vector3(myVector3 * scalar); }
101  HOM_Vector3 __rmul__(double scalar)
102  { return HOM_Vector3(myVector3 * scalar); }
103  HOM_Vector3 __mul__(HOM_Matrix3 &matrix3);
104  HOM_Vector3 __mul__(HOM_Matrix4 &matrix4);
105  HOM_Vector3 __div__(double scalar)
106  { return HOM_Vector3(myVector3 / scalar); }
107 
109  HOM_Vector3 multiplyAsDir(HOM_Matrix4 &matrix4);
110  double length()
111  { return myVector3.length(); }
112  double lengthSquared()
113  { return myVector3.length2(); }
114 
115 
116  SWIGOUT(%newobject matrixToRotateTo;)
117  HOM_Matrix4 *matrixToRotateTo(HOM_Vector3 &vector3);
118 
119  SWIGOUT(%kwargs smoothRotation;)
120  HOM_Vector3 smoothRotation(const HOM_Vector3 &reference,
121  const char *rotate_order = "xyz");
122 
123  double distanceTo(HOM_Vector3 &vector3);
124  double angleTo(HOM_Vector3 &vector3);
125 
126  double dot(HOM_Vector3 &vector3)
127  { return myVector3.dot(vector3.myVector3); }
129  { return ::cross(myVector3, vector3.myVector3); }
130 
131  HOM_Vector3 ocio_transform(const std::string &src_space,
132  const std::string &dest_space) const;
133 
134  double x()
135  { return myVector3.x(); }
136  double y()
137  { return myVector3.y(); }
138  double z()
139  { return myVector3.z(); }
140 
142  { return &myVector3; }
143 
144  double
145  distanceToSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
146 
147  double
148  distance2ToSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
149 
151  pointOnSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
152 
153  SWIGOUT(%ignore myVector3;)
154  UT_Vector3D myVector3;
155 };
156 
157 #endif
std::string __str__()
HOM_Vector3(const UT_Vector3D &vector3)
Definition: HOM_Vector3.h:38
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1130
int __hash__()
int __len__()
Definition: HOM_Vector3.h:76
bool operator!=(HOM_PtrOrNull< HOM_Vector3 > vector3)
Definition: HOM_Vector3.h:61
GLuint index
Definition: glew.h:1814
OIIO_API bool rename(string_view from, string_view to, std::string &err)
double dot(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:126
HOM_Vector3 __add__(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:93
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
HOM_Vector3 __rmul__(double scalar)
Definition: HOM_Vector3.h:101
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
HOM_Vector3(const std::vector< double > &sequence)
Definition: HOM_Vector3.h:47
HOM_Vector3 __mul__(double scalar)
Definition: HOM_Vector3.h:99
GLdouble GLdouble z
Definition: glew.h:1559
#define HOM_API
Definition: HOM_API.h:13
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
HOM_Vector3 __sub__(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:95
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
HOM_Matrix3 __mul__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:97
HOM_Vector3(const UT_Vector3F &vector3)
Definition: HOM_Vector3.h:43
bool operator==(HOM_PtrOrNull< HOM_Vector3 > vector3)
Definition: HOM_Vector3.h:58
HOM_Vector3 __div__(double scalar)
Definition: HOM_Vector3.h:105
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1129
void * _asVoidPointer()
Definition: HOM_Vector3.h:141
HOM_Vector3 __neg__()
Definition: HOM_Vector3.h:97
bool isAlmostEqual(HOM_Matrix3 &matrix3, double tolerance=0.00001)
HOM_Vector3(double x, double y, double z)
Definition: HOM_Vector3.h:33
double lengthSquared()
Definition: HOM_Vector3.h:112
GLsizei const GLchar *const * string
Definition: glew.h:1844
UT_Vector3D myVector3
Definition: HOM_Vector3.h:154
void setTo(const std::vector< double > &tuple)
double y()
Definition: HOM_Vector3.h:136
double z()
Definition: HOM_Vector3.h:138
double length()
Definition: HOM_Vector3.h:110
GLenum const void GLuint GLint reference
Definition: glew.h:13644
GLsizei const GLfloat * value
Definition: glew.h:1849
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
GLint GLenum GLboolean normalized
Definition: glew.h:1905
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:590
HOM_Vector3 cross(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:128
bool almostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
Definition: HOM_Vector3.h:67
double x()
Definition: HOM_Vector3.h:134