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 HOM_Vector2&);)
36  HOM_Vector2(const HOM_Vector2 &vector2)
37  : myVector2(vector2.myVector2)
38  { HOM_CONSTRUCT_OBJECT(this) }
39 
40  SWIGOUT(%ignore HOM_Vector2(const UT_Vector2D&);)
41  HOM_Vector2(const UT_Vector2D &vector2)
42  : myVector2(vector2)
43  { HOM_CONSTRUCT_OBJECT(this) }
44 
45  SWIGOUT(%ignore HOM_Vector2(const UT_Vector2F&);)
46  HOM_Vector2(const UT_Vector2F &vector2)
47  : myVector2(vector2)
48  { HOM_CONSTRUCT_OBJECT(this) }
49 
50  HOM_Vector2(const std::vector<double> &sequence)
51  {
53  setTo(sequence);
54  }
55 
57  { HOM_DESTRUCT_OBJECT(this) }
58 
60  { return vector2.myPointer && myVector2 == vector2.myPointer->myVector2; }
61 
63  { return !operator==(vector2); }
64 
65  bool isAlmostEqual(HOM_Vector2 &vector2, double tolerance=0.00001);
66 
67  // This method is deprecated.
68  bool almostEqual(HOM_Vector2 &vector2, double tolerance=0.00001)
69  { return isAlmostEqual(vector2, tolerance); }
70 
71  int __hash__();
74 
75  double __getitem__(int index);
76  void __setitem__(int index, double value);
77  int __len__()
78  { return 2; }
79 
80  // operator[] exists only to make this class easier to use from C++,
81  // and isn't wrapped by swig.
82  SWIGOUT(%ignore operator[];)
83  double &operator[](int index);
84 
85  void setTo(const std::vector<double> &sequence);
86 
87  SWIGOUT(%ignore operator=;)
88  HOM_Vector2 &operator=(const HOM_Vector2& vector2)
89  {
90  myVector2 = vector2.myVector2;
91  return *this;
92  }
93 
95  { return HOM_Vector2(myVector2 + vector2.myVector2); }
97  { return HOM_Vector2(myVector2 - vector2.myVector2); }
99  { return HOM_Vector2(-myVector2); }
100  HOM_Vector2 __mul__(double scalar)
101  { return HOM_Vector2(myVector2 * scalar); }
102  HOM_Vector2 __rmul__(double scalar)
103  { return HOM_Vector2(myVector2 * scalar); }
105  { return HOM_Vector2(myVector2 * matrix2.myMatrix2); }
106  HOM_Vector2 __div__(double scalar)
107  { return HOM_Vector2(myVector2 / scalar); }
108  HOM_Vector2 __truediv__(double scalar)
109  { return HOM_Vector2(myVector2 / scalar); }
110 
112  double length()
113  { return myVector2.length(); }
114  double lengthSquared()
115  { return myVector2.length2(); }
116 
117  double distanceTo(HOM_Vector2 &vector2);
118 
119  double dot(HOM_Vector2 &vector2)
120  { return myVector2.dot(vector2.myVector2); }
121 
122  double x()
123  { return myVector2.x(); }
124  double y()
125  { return myVector2.y(); }
126 
128  { return &myVector2; }
129 
130  SWIGOUT(%ignore myVector2;)
131  UT_Vector2D myVector2;
132 };
133 
134 #endif
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1238
void setTo(const std::vector< double > &sequence)
HOM_Vector2 __truediv__(double scalar)
Definition: HOM_Vector2.h:108
double dot(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:119
void __setitem__(int index, double value)
HOM_Vector2 __neg__()
Definition: HOM_Vector2.h:98
double x()
Definition: HOM_Vector2.h:122
double length()
Definition: HOM_Vector2.h:112
OIIO_API bool rename(string_view from, string_view to, std::string &err)
HOM_Vector2 __mul__(const HOM_Matrix2 &matrix2)
Definition: HOM_Vector2.h:104
bool operator==(HOM_PtrOrNull< HOM_Vector2 > vector2)
Definition: HOM_Vector2.h:59
#define SWIGOUT(x)
Definition: HOM_Defines.h:24
double __getitem__(int index)
string __repr__(VtArray< T > const &self)
Definition: wrapArray.h:353
HOM_Vector2(double x, double y)
Definition: HOM_Vector2.h:31
HOM_Vector2 __mul__(double scalar)
Definition: HOM_Vector2.h:100
GLint GLenum GLint x
Definition: glcorearb.h:408
void * _asVoidPointer()
Definition: HOM_Vector2.h:127
#define HOM_API
Definition: HOM_API.h:13
HOM_Vector2 __sub__(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:96
HOM_Vector2(const UT_Vector2F &vector2)
Definition: HOM_Vector2.h:46
GLint GLenum GLboolean normalized
Definition: glcorearb.h:871
double lengthSquared()
Definition: HOM_Vector2.h:114
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:1237
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
std::string __str__()
double y()
Definition: HOM_Vector2.h:124
bool operator!=(HOM_PtrOrNull< HOM_Vector2 > vector2)
Definition: HOM_Vector2.h:62
HOM_Vector2 __add__(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:94
HOM_Vector2(const UT_Vector2D &vector2)
Definition: HOM_Vector2.h:41
HOM_Vector2(const HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:36
double distanceTo(HOM_Vector3 &vector3)
GLuint index
Definition: glcorearb.h:785
UT_DMatrix2 myMatrix2
Definition: HOM_Matrix2.h:118
GLsizei const GLfloat * value
Definition: glcorearb.h:823
HOM_Vector2(const std::vector< double > &sequence)
Definition: HOM_Vector2.h:50
HOM_Vector2 __rmul__(double scalar)
Definition: HOM_Vector2.h:102
UT_Vector2D myVector2
Definition: HOM_Vector2.h:131
bool isAlmostEqual(HOM_Vector3 &vector3, double tolerance=0.00001)
int __len__()
Definition: HOM_Vector2.h:77
HOM_Vector2 __div__(double scalar)
Definition: HOM_Vector2.h:106
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
int __hash__()
bool almostEqual(HOM_Vector2 &vector2, double tolerance=0.00001)
Definition: HOM_Vector2.h:68