HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
105  double length()
106  { return myVector2.length(); }
107  double lengthSquared()
108  { return myVector2.length2(); }
109 
110  double distanceTo(HOM_Vector2 &vector2);
111 
112  double dot(HOM_Vector2 &vector2)
113  { return myVector2.dot(vector2.myVector2); }
114 
115  double x()
116  { return myVector2.x(); }
117  double y()
118  { return myVector2.y(); }
119 
121  { return &myVector2; }
122 
123  SWIGOUT(%ignore myVector2;)
124  UT_Vector2D myVector2;
125 };
126 
127 #endif
#define HOM_DESTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:983
void setTo(const std::vector< double > &sequence)
double dot(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:112
void __setitem__(int index, double value)
HOM_Vector2 __neg__()
Definition: HOM_Vector2.h:93
double x()
Definition: HOM_Vector2.h:115
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
double length()
Definition: HOM_Vector2.h:105
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)
GLint y
Definition: glcorearb.h:102
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:120
#define HOM_API
Definition: HOM_API.h:13
HOM_Vector2 __sub__(HOM_Vector2 &vector2)
Definition: HOM_Vector2.h:91
HOM_Vector2(const UT_Vector2F &vector2)
Definition: HOM_Vector2.h:41
double lengthSquared()
Definition: HOM_Vector2.h:107
#define HOM_CONSTRUCT_OBJECT(pointer)
Definition: HOM_Module.h:982
std::string __str__()
double y()
Definition: HOM_Vector2.h:117
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
GLint GLenum GLboolean normalized
Definition: glcorearb.h:871
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double distanceTo(HOM_Vector3 &vector3)
GLuint index
Definition: glcorearb.h:785
GLint GLenum GLint x
Definition: glcorearb.h:408
UT_DMatrix2 myMatrix2
Definition: HOM_Matrix2.h:111
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:124
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
std::string __repr__()
bool operator==(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Equality operator, does exact floating point comparisons.
Definition: Mat3.h:596
int __hash__()
bool almostEqual(HOM_Vector2 &vector2, double tolerance=0.00001)
Definition: HOM_Vector2.h:63