HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HOM_Vector2.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_Vector2_h__
10 #define __HOM_Vector2_h__
11 
12 #include "HOM_API.h"
13 #include "HOM_Defines.h"
14 #include "HOM_Errors.h"
15 #include "HOM_Matrix2.h"
16 #include "HOM_Module.h"
17 #include "HOM_PtrOrNull.h"
18 #include <UT/UT_Vector2.h>
19 #include <vector>
20 #include <stdexcept>
21 
22 SWIGOUT(%rename(Vector2) HOM_Vector2;)
23 
25 {
26 public:
28  : myVector2(0.0, 0.0)
29  { HOM_CONSTRUCT_OBJECT(this) }
30 
31  HOM_Vector2(double x, double y)
32  : myVector2(x, y)
33  { HOM_CONSTRUCT_OBJECT(this) }
34 
35  SWIGOUT(%ignore HOM_Vector2(const UT_Vector2D&);)
36  HOM_Vector2(const UT_Vector2D &vector2)
37  : myVector2(vector2)
38  { HOM_CONSTRUCT_OBJECT(this) }
39 
40  SWIGOUT(%ignore HOM_Vector2(const UT_Vector2F&);)
41  HOM_Vector2(const UT_Vector2F &vector2)
42  : myVector2(vector2)
43  { HOM_CONSTRUCT_OBJECT(this) }
44 
45  HOM_Vector2(const std::vector<double> &sequence)
46  {
48  setTo(sequence);
49  }
50 
52  { HOM_DESTRUCT_OBJECT(this) }
53 
55  { return vector2.myPointer && myVector2 == vector2.myPointer->myVector2; }
56 
58  { return !operator==(vector2); }
59 
60  bool isAlmostEqual(HOM_Vector2 &vector2, double tolerance=0.00001);
61 
62  // This method is deprecated.
63  bool almostEqual(HOM_Vector2 &vector2, double tolerance=0.00001)
64  { return isAlmostEqual(vector2, tolerance); }
65 
66  int __hash__();
69 
70  double __getitem__(int index);
71  void __setitem__(int index, double value);
72  int __len__()
73  { return 2; }
74 
75  // operator[] exists only to make this class easier to use from C++,
76  // and isn't wrapped by swig.
77  SWIGOUT(%ignore operator[];)
78  double &operator[](int index);
79 
80  void setTo(const std::vector<double> &sequence);
81 
82  SWIGOUT(%ignore operator=;)
83  HOM_Vector2 &operator=(const HOM_Vector2& vector2)
84  {
85  myVector2 = vector2.myVector2;
86  return *this;
87  }
88 
90  { return HOM_Vector2(myVector2 + vector2.myVector2); }
92  { return HOM_Vector2(myVector2 - vector2.myVector2); }
94  { return HOM_Vector2(-myVector2); }
95  HOM_Vector2 __mul__(double scalar)
96  { return HOM_Vector2(myVector2 * scalar); }
97  HOM_Vector2 __rmul__(double scalar)
98  { return HOM_Vector2(myVector2 * scalar); }
100  { return HOM_Vector2(myVector2 * matrix2.myMatrix2); }
101  HOM_Vector2 __div__(double scalar)
102  { return HOM_Vector2(myVector2 / scalar); }
103  HOM_Vector2 __truediv__(double scalar)
104  { return HOM_Vector2(myVector2 / scalar); }
105 
107  double length()
108  { return myVector2.length(); }
109  double lengthSquared()
110  { return myVector2.length2(); }
111 
112  double distanceTo(HOM_Vector2 &vector2);
113 
114  double dot(HOM_Vector2 &vector2)
115  { return myVector2.dot(vector2.myVector2); }
116 
117  double x()
118  { return myVector2.x(); }
119  double y()
120  { return myVector2.y(); }
121 
123  { return &myVector2; }
124 
125  SWIGOUT(%ignore myVector2;)
126  UT_Vector2D myVector2;
127 };
128 
129 #endif
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1209
void setTo(const std::vector< double > &sequence)
HOM_Vector2 __truediv__(double scalar)
Definition: HOM_Vector2.h:103
double dot(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:114
GLuint index
Definition: glew.h:1814
void __setitem__(int index, double value)
HOM_Vector2 __neg__()
Definition: HOM_Vector2.h:93
double x()
Definition: HOM_Vector2.h:117
double length()
Definition: HOM_Vector2.h:107
OIIO_API bool rename(string_view from, string_view to, std::string &err)
HOM_Vector2 __mul__(const HOM_Matrix2 &matrix2)
Definition: HOM_Vector2.h:99
bool operator==(HOM_PtrOrNull< HOM_Vector2 > vector2)
Definition: HOM_Vector2.h:54
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
double __getitem__(int index)
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:349
HOM_Vector2(double x, double y)
Definition: HOM_Vector2.h:31
HOM_Vector2 __mul__(double scalar)
Definition: HOM_Vector2.h:95
void * _asVoidPointer()
Definition: HOM_Vector2.h:122
#define HOM_API
Definition: HOM_API.h:13
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
HOM_Vector2 __sub__(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:91
HOM_Vector2(const UT_Vector2F &vector2)
Definition: HOM_Vector2.h:41
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
double lengthSquared()
Definition: HOM_Vector2.h:109
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1208
std::string __str__()
double y()
Definition: HOM_Vector2.h:119
bool operator!=(HOM_PtrOrNull< HOM_Vector2 > vector2)
Definition: HOM_Vector2.h:57
HOM_Vector2 __add__(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:89
HOM_Vector2(const UT_Vector2D &vector2)
Definition: HOM_Vector2.h:36
GLsizei const GLchar *const * string
Definition: glew.h:1844
double distanceTo(HOM_Vector3 &vector3)
UT_DMatrix2 myMatrix2
Definition: HOM_Matrix2.h:114
HOM_Vector2(const std::vector< double > &sequence)
Definition: HOM_Vector2.h:45
HOM_Vector2 __rmul__(double scalar)
Definition: HOM_Vector2.h:97
UT_Vector2D myVector2
Definition: HOM_Vector2.h:126
bool isAlmostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
int __len__()
Definition: HOM_Vector2.h:72
HOM_Vector2 __div__(double scalar)
Definition: HOM_Vector2.h:101
GLsizei const GLfloat * value
Definition: glew.h:1849
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:563
int __hash__()
bool almostEqual(HOM_Vector2 &vector2, double tolerance=0.00001)
Definition: HOM_Vector2.h:63