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 
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 
38  HOM_Vector3(const HOM_Vector3 &vector3)
39  : myVector3(vector3.myVector3)
40  { HOM_CONSTRUCT_OBJECT(this) }
41 
43  HOM_Vector3(const UT_Vector3D &vector3)
44  : myVector3(vector3)
45  { HOM_CONSTRUCT_OBJECT(this) }
46 
48  HOM_Vector3(const UT_Vector3F &vector3)
49  : myVector3(vector3)
50  { HOM_CONSTRUCT_OBJECT(this) }
51 
52  HOM_Vector3(const std::vector<double> &sequence)
53  {
55  setTo(sequence);
56  }
57 
58  HOM_Vector3(HOM_Vector4 &vector4);
59 
61  { HOM_DESTRUCT_OBJECT(this) }
62 
64  { return vector3.myPointer && myVector3 == vector3.myPointer->myVector3; }
65 
67  { return !operator==(vector3); }
68 
69  bool isAlmostEqual(HOM_Vector3 &vector3, double tolerance=0.00001);
70 
71  // This method is deprecated.
72  bool almostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
73  { return isAlmostEqual(vector3, tolerance); }
74 
75  int __hash__();
78 
79  double __getitem__(int index);
80  void __setitem__(int index, double value);
81  int __len__()
82  { return 3; }
83 
84  // operator[] exists only to make this class easier to use from C++,
85  // and isn't wrapped by swig.
86  SWIGOUT(%ignore operator[];)
87  double &operator[](int index);
88 
89  void setTo(const std::vector<double> &sequence);
90 
91  SWIGOUT(%ignore operator=;)
92  HOM_Vector3 &operator=(const HOM_Vector3& vector3)
93  {
94  myVector3 = vector3.myVector3;
95  return *this;
96  }
97 
99  { return HOM_Vector3(myVector3 + vector3.myVector3); }
101  { return HOM_Vector3(myVector3 - vector3.myVector3); }
103  { return HOM_Vector3(-myVector3); }
104  HOM_Vector3 __mul__(double scalar)
105  { return HOM_Vector3(myVector3 * scalar); }
106  HOM_Vector3 __rmul__(double scalar)
107  { return HOM_Vector3(myVector3 * scalar); }
108  HOM_Vector3 __mul__(HOM_Matrix3 &matrix3);
109  HOM_Vector3 __mul__(HOM_Matrix4 &matrix4);
110  HOM_Vector3 __div__(double scalar)
111  { return HOM_Vector3(myVector3 / scalar); }
112  HOM_Vector3 __truediv__(double scalar)
113  { return HOM_Vector3(myVector3 / scalar); }
114 
116  HOM_Vector3 multiplyAsDir(HOM_Matrix4 &matrix4);
117  double length()
118  { return myVector3.length(); }
119  double lengthSquared()
120  { return myVector3.length2(); }
121 
122 
123  SWIGOUT(%newobject matrixToRotateTo;)
124  HOM_Matrix4 *matrixToRotateTo(HOM_Vector3 &vector3);
125 
126  SWIGOUT(%kwargs smoothRotation;)
127  HOM_Vector3 smoothRotation(const HOM_Vector3 &reference,
128  const char *rotate_order = "xyz");
129 
130  double distanceTo(HOM_Vector3 &vector3);
131  double angleTo(HOM_Vector3 &vector3);
132 
133  double dot(HOM_Vector3 &vector3)
134  { return myVector3.dot(vector3.myVector3); }
136  { return ::cross(myVector3, vector3.myVector3); }
137 
138  HOM_Vector3 ocio_transform(const std::string &src_space,
139  const std::string &dest_space) const;
140 
141  double x()
142  { return myVector3.x(); }
143  double y()
144  { return myVector3.y(); }
145  double z()
146  { return myVector3.z(); }
147 
149  { return &myVector3; }
150 
151  double
152  distanceToSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
153 
154  double
155  distance2ToSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
156 
158  pointOnSegment(HOM_Vector3 const& point1, HOM_Vector3 const& point2) const;
159 
160  SWIGOUT(%ignore myVector3;)
161  UT_Vector3D myVector3;
162 };
163 
164 #endif
std::string __str__()
HOM_Vector3(const UT_Vector3D &vector3)
Definition: HOM_Vector3.h:43
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1291
int __hash__()
int __len__()
Definition: HOM_Vector3.h:81
bool operator!=(HOM_PtrOrNull< HOM_Vector3 > vector3)
Definition: HOM_Vector3.h:66
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
double dot(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:133
HOM_Vector3 __add__(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:98
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
HOM_Vector3 __rmul__(double scalar)
Definition: HOM_Vector3.h:106
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:352
GLint y
Definition: glcorearb.h:103
HOM_Vector3(const std::vector< double > &sequence)
Definition: HOM_Vector3.h:52
HOM_Vector3 __mul__(double scalar)
Definition: HOM_Vector3.h:104
#define HOM_API
Definition: HOM_API.h:13
HOM_Vector3 __sub__(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:100
void ignore(T const &) VULKAN_HPP_NOEXCEPT
Definition: vulkan.hpp:6508
HOM_Matrix3 __mul__(HOM_Matrix3 &matrix3)
Definition: HOM_Matrix3.h:104
HOM_Vector3(const UT_Vector3F &vector3)
Definition: HOM_Vector3.h:48
bool operator==(HOM_PtrOrNull< HOM_Vector3 > vector3)
Definition: HOM_Vector3.h:63
HOM_Vector3 __div__(double scalar)
Definition: HOM_Vector3.h:110
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1290
void * _asVoidPointer()
Definition: HOM_Vector3.h:148
HOM_Vector3 __neg__()
Definition: HOM_Vector3.h:102
bool isAlmostEqual(HOM_Matrix3 &matrix3, double tolerance=0.00001)
GLint GLenum GLboolean normalized
Definition: glcorearb.h:872
HOM_Vector3(double x, double y, double z)
Definition: HOM_Vector3.h:33
GLint GLenum GLint x
Definition: glcorearb.h:409
double lengthSquared()
Definition: HOM_Vector3.h:119
UT_Vector3D myVector3
Definition: HOM_Vector3.h:161
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
Definition: Types.h:305
void setTo(const std::vector< double > &tuple)
GLuint index
Definition: glcorearb.h:786
HOM_Vector3 __truediv__(double scalar)
Definition: HOM_Vector3.h:112
double y()
Definition: HOM_Vector3.h:143
double z()
Definition: HOM_Vector3.h:145
double length()
Definition: HOM_Vector3.h:117
HOM_Vector3(const HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:38
Definition: core.h:1131
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:542
HOM_Vector3 cross(HOM_Vector3 &vector3)
Definition: HOM_Vector3.h:135
bool almostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
Definition: HOM_Vector3.h:72
double x()
Definition: HOM_Vector3.h:141