Point.h
Go to the documentation of this file.
1 /********************************************************************
2  *
3  * Project Artec 3D Scanning SDK
4  *
5  * Purpose: Definition of template point classes (with 2, 3 and 4 dimensions)
6  *
7  * Copyright: Artec Group
8  *
9  ********************************************************************/
10 
11 #ifndef _POINT_H_
12 #define _POINT_H_
13 
14 #include <cmath>
15 #include <limits>
16 #include <algorithm>
17 
18 namespace artec { namespace sdk { namespace base
19 {
20 
21 template < typename T > class Point3;
22 template < typename T > class Point4;
23 
24 /// Equality expression for types which are not exact
25 template < typename Tf > bool isZero(const Tf & some)
26 {
27  return some <= std::numeric_limits< Tf >::epsilon() &&
28  some >= -std::numeric_limits< Tf >::epsilon();
29 }
30 
31 /**
32 * 2-dimensional point class. Coordinates are of type T.
33 */
34 
35 template < typename T >
36 class Point2
37 {
38 public:
39  typedef T value_type;
40 
41  /// Constructor. Empty for fast points array allocation.
42  explicit Point2() : x(T()), y(T()) {}
43 
44  explicit Point2(T tx, T ty) : x(tx), y(ty) {}
45 
46  /// Copying constructor
47  Point2(const Point2& ot) : x(ot.x), y(ot.y) {}
48 
49  /// Assignment operator
50  Point2& operator=(const Point2& ot) { x = ot.x; y = ot.y; return *this; }
51 
52  /// Point3 conversion
53  Point2(const Point3<T>& ot) : x(ot.x), y(ot.y) {}
54  Point2& operator=(const Point3<T>& ot) { x = ot.x; y = ot.y; return *this; }
55 
56  /// Point4 conversion
57  Point2(const Point4<T>& ot) : x(ot.x), y(ot.y) {}
58  Point2& operator=(const Point4<T>& ot) { x = ot.x; y = ot.y; return *this; }
59 
60  /// Type conversion
61  template< typename T2 > explicit Point2(const Point2< T2 > &ot) : x(ot.x), y(ot.y) {}
62 
63  ///@{
64  /// Arithmetical operations with scalar type
65  template < typename T2 > Point2<T> & operator+=(const T2 & val) { x+=val; y+=val; return *this; }
66  template < typename T2 > Point2<T> & operator-=(const T2 & val) { x-=val; y-=val; return *this; }
67  template < typename T2 > Point2<T> & operator*=(const T2 & val) { x*=val; y*=val; return *this; }
68  template < typename T2 > Point2<T> & operator/=(const T2 & val) { x/=val; y/=val; return *this; }
69 
70  template < typename T2 > Point2<T> operator+(const T2 & val) const
71  { Point2<T> ret = *this; return ret += val; }
72  template < typename T2 > Point2<T> operator-(const T2 & val) const
73  { Point2<T> ret = *this; return ret -= val; }
74  template < typename T2 > Point2<T> operator*(const T2 & val) const
75  { Point2<T> ret = *this; return ret *= val; }
76  template < typename T2 > Point2<T> operator/(const T2 & val) const
77  { Point2<T> ret = *this; return ret /= val; }
78  ///@}
79 
80  ///@{
81  /// Arithmetical operations with point
82  Point2 & operator+=(const Point2& ot) { x+=ot.x; y+=ot.y; return *this; }
83  Point2 & operator-=(const Point2& ot) { x-=ot.x; y-=ot.y; return *this; }
84  Point2 & operator*=(const Point2& ot) { x*=ot.x; y*=ot.y; return *this; }
85  Point2 & operator/=(const Point2& ot) { x/=ot.x; y/=ot.y; return *this; }
86 
87  Point2 operator+(const Point2& p2) const { Point2 ret = *this; return ret += p2; }
88  Point2 operator-(const Point2& p2) const { Point2 ret = *this; return ret -= p2; }
89  Point2 operator*(const Point2& p2) const { Point2 ret = *this; return ret *= p2; }
90  Point2 operator/(const Point2& p2) const { Point2 ret = *this; return ret /= p2; }
91  ///@}
92 
93  /// Unary minus
94  Point2 operator-() const { return Point2(-x,-y); }
95 
96  ///@{
97  /// Logical operations
98  bool operator==(const Point2& p2) const { return artec::sdk::base::isZero(x-p2.x) && artec::sdk::base::isZero(y-p2.y); }
99  bool operator!=(const Point2& p2) const { return !(*this == p2); }
100  bool operator>(const Point2& p2) const { return x>p2.x && y>p2.y; }
101  bool operator>=(const Point2& p2) const { return (x>p2.x || artec::sdk::base::isZero(x-p2.x)) && (y>p2.y || artec::sdk::base::isZero(y-p2.y)); }
102  bool operator<(const Point2& p2) const { return x<p2.x && y<p2.y; }
103  bool operator<=(const Point2& p2) const { return (x<p2.x || artec::sdk::base::isZero(x-p2.x)) && (y<p2.y || artec::sdk::base::isZero(y-p2.y)); }
104  ///@}
105 
106  /// Inner product operator
107  static T dot(const Point2<T>& p1, const Point2<T>& p2)
108  {
109  return (p1.x*p2.x + p1.y*p2.y);
110  }
111 
112  /// Conversion to plain form operator
113  operator T * () { return data; }
114  operator const T * () const { return data; }
115 
116  /// Length of point
117  double length() const { return sqrt((double)x*x+y*y); }
118 
119  /// Square of length of point
120  double lengthSquared() const { return (double)x*x+y*y; }
121 
122  /// normalizing to unit vector in euclidean norm
123  void normalize()
124  {
125  double len = length();
126  if (!artec::sdk::base::isZero(len))
127  {
128  x = (T)(x / len);
129  y = (T)(y / len);
130  }
131  }
132 
134  {
135  double len = length();
136  if (!artec::sdk::base::isZero(len))
137  return *this / len;
138  else
139  return Point2();
140  }
141 
142  /// Zero checking
144 
145  /// Reset values to default
146  void reset() { x = y = T(); }
147 
148 public:
149 
150  /// point data
151  union
152  {
153  struct
154  {
155  T x,y;
156  };
157 
158  T data[2];
159  };
160 
161  static const int size_ = 2;
162 };
163 
164 /// Distance measure (squared)
165 template<typename T> inline T distanceSquare(const Point2<T>& p1, const Point2<T>& p2)
166 {
167  return (p1 - p2).lengthSquared();
168 }
169 
170 /// Cross product of two points
171 template<typename T> inline T dotProduct(const Point2<T>& p1, const Point2<T>& p2)
172 {
173  return (p1.x*p2.x + p1.y*p2.y);
174 }
175 
176 /// Arithmetic operators of the form: operator(scalar, TPoint2)
177 template < typename T, typename T2 > inline
178  Point2<T> operator+(const T2 & val, const Point2<T> & p) { return p + val; }
179 template < typename T, typename T2 > inline
180  Point2<T> operator-(const T2 & val, const Point2<T> & p) { return -p + val; }
181 template < typename T, typename T2 > inline
182  Point2<T> operator*(const T2 & val, const Point2<T> & p) { return p*val; }
183 
184 
185 /**
186 * 3-dimensional point class. Coordinates are of type T.
187 */
188 
189 template <typename T>
190 class Point3
191 {
192 public:
193  typedef T value_type;
194 
195  /// Constructor. Empty for fast points array allocation.
196  explicit Point3() : x(T()), y(T()), z(T()) {}
197 
198  explicit Point3(T tx, T ty, T tz) : x(tx), y(ty), z(tz) {}
199 
200  /// Copying constructor
201  Point3(const Point3& ot) : x(ot.x), y(ot.y), z(ot.z) {}
202 
203  /// Assignment operator
204  Point3& operator=(const Point3& ot) { x=ot.x; y=ot.y; z=ot.z; return *this; }
205 
206  /// Point2 conversion
207  Point3(const Point2<T>& ot) : x(ot.x), y(ot.y), z(T()) {}
208  Point3& operator=(const Point2<T>& ot) { x = ot.x; y = ot.y; z = T(); return *this; }
209 
210  /// Point4 conversion
211  Point3(const Point4<T>& ot) : x(ot.x), y(ot.y), z(ot.z) {}
212  Point3& operator=(const Point4<T>& ot) { x = ot.x; y = ot.y; z = ot.z; return *this; }
213 
214  /// Type conversion
215  template< typename T2 > explicit Point3(const Point3< T2 > &ot) : x(T(ot.x)), y(T(ot.y)), z(T(ot.z)) {}
216 
217  ///@{
218  /// Arithmetical operations with scalar type
219  template < typename T2 > Point3<T>& operator+=(const T2 & val) { x+=val; y+=val; z+=val; return *this; }
220  template < typename T2 > Point3<T>& operator-=(const T2 & val) { x-=val; y-=val; z-=val; return *this; }
221  template < typename T2 > Point3<T>& operator*=(const T2 & val) { x*=val; y*=val; z*=val; return *this; }
222  template < typename T2 > Point3<T>& operator/=(const T2 & val) { x/=val; y/=val; z/=val; return *this; }
223 
224  template < typename T2 > Point3<T> operator+(const T2 & val) const
225  { Point3<T> ret = *this; return ret += val; }
226  template < typename T2 > Point3<T> operator-(const T2 & val) const
227  { Point3<T> ret = *this; return ret -= val; }
228  template < typename T2 > Point3<T> operator*(const T2 & val) const
229  { Point3<T> ret = *this; return ret *= val; }
230  template < typename T2 > Point3<T> operator/(const T2 & val) const
231  { Point3<T> ret = *this; return ret /= val; }
232  ///@}
233 
234  ///@{
235  /// Arithmetical operations with point
236  Point3& operator+=(const Point3& ot) { x+=ot.x; y+=ot.y; z+=ot.z; return *this; }
237  Point3& operator-=(const Point3& ot) { x-=ot.x; y-=ot.y; z-=ot.z; return *this; }
238  Point3& operator*=(const Point3& ot) { x*=ot.x; y*=ot.y; z*=ot.z; return *this; }
239  Point3& operator/=(const Point3& ot) { x/=ot.x; y/=ot.y; z/=ot.z; return *this; }
240 
241  Point3 operator+(const Point3& p2) const { Point3 ret = *this; return ret += p2; }
242  Point3 operator-(const Point3& p2) const { Point3 ret = *this; return ret -= p2; }
243  Point3 operator*(const Point3& p2) const { Point3 ret = *this; return ret *= p2; }
244  Point3 operator/(const Point3& p2) const { Point3 ret = *this; return ret /= p2; }
245  ///@}
246 
247  /// Unary minus
248  Point3 operator-() const { return Point3(-x, -y, -z); }
249 
250  ///@{
251  /// Logical operations
252  bool operator==(const Point3& p2) const
253  {
255  }
256  bool operator!=(const Point3& p2) const { return !(*this == p2); }
257  bool operator>(const Point3& p2) const { return x>p2.x && y>p2.y && z>p2.z; }
258  bool operator>=(const Point3& p2) const
259  {
260  return (x>p2.x || artec::sdk::base::isZero(x-p2.x)) && (y>p2.y || artec::sdk::base::isZero(y-p2.y)) && (z>p2.z || artec::sdk::base::isZero(z-p2.z));
261  }
262  bool operator<(const Point3& p2) const { return x<p2.x && y<p2.y && z<p2.z; }
263  bool operator<=(const Point3& p2) const
264  {
265  return (x<p2.x || artec::sdk::base::isZero(x-p2.x)) && (y<p2.y || artec::sdk::base::isZero(y-p2.y)) && (z<p2.z || artec::sdk::base::isZero(z-p2.z));
266  }
267  ///@}
268 
269  /// Inner product operator
270  static T dot(const Point3<T>& p1, const Point3<T>& p2)
271  {
272  return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z);
273  }
274 
275  /// Cross product of two points
276  static Point3<T> cross(const Point3<T>& p1, const Point3<T>& p2)
277  {
278  return Point3<T>(p1.y*p2.z - p1.z*p2.y, p1.z*p2.x - p1.x*p2.z, p1.x*p2.y - p1.y*p2.x);
279  }
280 
281  /// Conversion to plain form operator
282  operator T * () { return data; }
283  operator const T * () const { return data; }
284 
285  /// Length of point
286  double length() const { return sqrt((double)x*x+y*y+z*z); }
287 
288  /// Square of length of point
289  double lengthSquared() const { return (double)x*x+y*y+z*z; }
290 
291  /// normalizing to unit vector in euclidean norm
292  void normalize()
293  {
294  double len = length();
295  if (!artec::sdk::base::isZero(len))
296  {
297  x = (T)(x / len);
298  y = (T)(y / len);
299  z = (T)(z / len);
300  }
301  }
302 
304  {
305  double len = length();
306  if (!artec::sdk::base::isZero(len))
307  return *this / len;
308  else
309  return Point3();
310  }
311 
312  /// Zero checking
314 
315  /// Reset values to default
316  void reset() { x = y = z = T(); }
317 
318 public:
319 
320  /// point data
321  union
322  {
323  struct
324  {
325  T x,y,z;
326  };
327 
328  T data[3];
329  };
330 
331  static const int size_ = 3;
332 };
333 
334 /// Distance measure (squared)
335 template<typename T> inline T distanceSquare(const Point3<T>& p1, const Point3<T>& p2)
336 {
337  return (p1 - p2).lengthSquared();
338 }
339 
340 /// Cross product of two points
341 template<typename T> inline T dotProduct(const Point3<T>& p1, const Point3<T>& p2)
342 {
343  return Point3<T>::dot(p1, p2);
344 }
345 
346 /// Cross product of two points
347 template<typename T> inline Point3<T> crossProduct(const Point3<T>& p1, const Point3<T>& p2)
348 {
349  return Point3<T>::cross(p1, p2);
350 }
351 
352 /**
353 * 4-dimensional point class. Coordinates are of type T.
354 */
355 template < typename T >
356 class Point4
357 {
358 public:
359  typedef T value_type;
360 
361  /// Constructor. Empty for fast points array allocation.
362  explicit Point4() : x(T()), y(T()), z(T()), w(T()) {}
363 
364  explicit Point4(T tx, T ty, T tz, T tw) : x(tx), y(ty), z(tz), w(tw) {}
365 
366  /// Copying constructor
367  Point4(const Point4& ot) : x(ot.x), y(ot.y), z(ot.z), w(ot.w) {}
368 
369  /// Assignment operator
370  Point4& operator=(const Point4& ot) { x = ot.x; y = ot.y; z = ot.z; w = ot.w; return *this; }
371 
372  /// Point2 conversion
373  Point4(const Point2<T>& ot) : x(ot.x), y(ot.y), z(T()), w(T()) {}
374  Point4& operator=(const Point2<T>& ot) { x = ot.x; y = ot.y; z = T(); w = T(); return *this; }
375 
376  /// Point3 conversion
377  Point4(const Point3<T>& ot) : x(ot.x), y(ot.y), z(ot.z), w(T()) {}
378  Point4& operator=(const Point3<T>& ot) { x = ot.x; y = ot.y; z = ot.z; w = T(); return *this; }
379 
380  /// Type conversion
381  template< typename T2 > explicit Point4(const Point4< T2 > &ot) : x(ot.x), y(ot.y), z(ot.z), w(ot.w) {}
382 
383  ///@{
384  /// Arithmetical operations with scalar type
385  template < typename T2 > Point4<T> & operator+=(const T2 & val) { x+=val; y+=val; z += val; w += val; return *this; }
386  template < typename T2 > Point4<T> & operator-=(const T2 & val) { x-=val; y-=val; z -= val; w -= val; return *this; }
387  template < typename T2 > Point4<T> & operator*=(const T2 & val) { x*=val; y*=val; z *= val; w *= val; return *this; }
388  template < typename T2 > Point4<T> & operator/=(const T2 & val) { x/=val; y/=val; z /= val; w /= val; return *this; }
389 
390  template < typename T2 > Point4<T> operator+(const T2 & val) const
391  { Point4<T> ret = *this; return ret += val; }
392  template < typename T2 > Point4<T> operator-(const T2 & val) const
393  { Point4<T> ret = *this; return ret -= val; }
394  template < typename T2 > Point4<T> operator*(const T2 & val) const
395  { Point4<T> ret = *this; return ret *= val; }
396  template < typename T2 > Point4<T> operator/(const T2 & val) const
397  { Point4<T> ret = *this; return ret /= val; }
398  ///@}
399 
400  ///@{
401  /// Arithmetical operations with point
402  Point4 & operator+=(const Point4& ot) { x+=ot.x; y+=ot.y; z+=ot.z; w+=ot.w; return *this; }
403  Point4 & operator-=(const Point4& ot) { x-=ot.x; y-=ot.y; z-=ot.z; w-=ot.w; return *this; }
404  Point4 & operator*=(const Point4& ot) { x*=ot.x; y*=ot.y; z*=ot.z; w*=ot.w; return *this; }
405  Point4 & operator/=(const Point4& ot) { x/=ot.x; y/=ot.y; z/=ot.z; w/=ot.w; return *this; }
406 
407  Point4 operator+(const Point4& p2) const { Point4 ret = *this; return ret += p2; }
408  Point4 operator-(const Point4& p2) const { Point4 ret = *this; return ret -= p2; }
409  Point4 operator*(const Point4& p2) const { Point4 ret = *this; return ret *= p2; }
410  Point4 operator/(const Point4& p2) const { Point4 ret = *this; return ret /= p2; }
411  ///@}
412 
413  /// Unary minus
414  Point4 operator-() const { return Point4(-x,-y,-z,-w); }
415 
416  ///@{
417  /// Logical operations
419  bool operator!=(const Point4& p2) const { return !(*this == p2); }
420  bool operator>(const Point4& p2) const { return x>p2.x && y>p2.y && z>p2.z && w>p2.w; }
421  bool operator>=(const Point4& p2) const { return (x>p2.x || artec::sdk::base::isZero(x-p2.x)) && (y>p2.y || artec::sdk::base::isZero(y-p2.y)) && (z>p2.z || artec::sdk::base::isZero(z-p2.z)) && (w>p2.w || artec::sdk::base::isZero(w-p2.w)); }
422  bool operator<(const Point4& p2) const { return x<p2.x && y<p2.y && z<p2.z && w<p2.w; }
423  bool operator<=(const Point4& p2) const { return (x<p2.x || artec::sdk::base::isZero(x-p2.x)) && (y<p2.y || artec::sdk::base::isZero(y-p2.y)) && (z<p2.z || artec::sdk::base::isZero(z-p2.z)) && (w<p2.w || artec::sdk::base::isZero(w-p2.w)); }
424  ///@}
425 
426  /// Inner product operator
427  static T dot(const Point4<T>& p1, const Point4<T>& p2)
428  {
429  return (p1.x*p2.x + p1.y*p2.y + p1.z*p2.z + p1.w*p2.w);
430  }
431 
432  /// Conversion to plain form operator
433  operator T * () { return data; }
434  operator const T * () const { return data; }
435 
436  /// Length of point
437  double length() const { return sqrt((double)x*x+y*y+z*z+w*w); }
438 
439  /// Square of length of point
440  double lengthSquared() const { return (double)x*x+y*y+z*z+w*w; }
441 
442  /// normalizing to unit vector in euclidean norm
443  void normalize()
444  {
445  double len = length();
446  if (!artec::sdk::base::isZero(len))
447  {
448  x = (T)(x / len);
449  y = (T)(y / len);
450  z = (T)(z / len);
451  w = (T)(w / len);
452  }
453  }
454 
456  {
457  double len = length();
458  if (!artec::sdk::base::isZero(len))
459  return *this / len;
460  else
461  return Point4();
462  }
463 
464  /// Zero checking
466 
467  /// Reset values to default
468  void reset() { x = y = z = w = T(); }
469 
470 public:
471 
472  /// point data
473  union
474  {
475  struct
476  {
477  T x,y,z,w;
478  };
479 
480  T data[4];
481  };
482 
483  static const int size_ = 4;
484 };
485 
486 /// Distance measure (squared)
487 template<typename T> inline T distanceSquare(const Point4<T>& p1, const Point4<T>& p2)
488 {
489  return (p1 - p2).lengthSquared();
490 }
491 
492 /// Cross product of two points
493 template<typename T> inline T dotProduct(const Point4<T>& p1, const Point4<T>& p2)
494 {
495  return Point4<T>::dot(p1, p2);
496 }
497 
498 /**
499 * Commonly used points shortcuts
500 */
504 
508 
512 
513 } } } // namespace artec::sdk::base
514 
515 #endif //_POINT_H_
Point2< T > operator+(const T2 &val, const Point2< T > &p)
Arithmetic operators of the form: operator(scalar, TPoint2)
Definition: Point.h:178
Point3< T > & operator/=(const T2 &val)
Definition: Point.h:222
Point2 normalized() const
Definition: Point.h:133
Point3 operator-(const Point3 &p2) const
Definition: Point.h:242
bool isZero() const
Zero checking.
Definition: Point.h:143
Point2 operator-() const
Unary minus.
Definition: Point.h:94
Point2< T > operator*(const T2 &val) const
Definition: Point.h:74
Point4 & operator=(const Point3< T > &ot)
Definition: Point.h:378
Point3(const Point4< T > &ot)
Point4 conversion.
Definition: Point.h:211
bool operator>=(const Point4 &p2) const
Definition: Point.h:421
Point3 & operator*=(const Point3 &ot)
Definition: Point.h:238
bool operator==(const Point3 &p2) const
Definition: Point.h:252
bool operator<(const Point3 &p2) const
Definition: Point.h:262
Point3 operator*(const Point3 &p2) const
Definition: Point.h:243
Point2(const Point3< T > &ot)
Point3 conversion.
Definition: Point.h:53
Point4< T > operator+(const T2 &val) const
Definition: Point.h:390
double lengthSquared() const
Square of length of point.
Definition: Point.h:289
bool operator>(const Point4 &p2) const
Definition: Point.h:420
bool operator<(const Point2 &p2) const
Definition: Point.h:102
Point4 normalized() const
Definition: Point.h:455
bool operator<(const Point4 &p2) const
Definition: Point.h:422
Point3< Type2 > operator*(const GenericMatrix< 3, 3, Type > &matrix, const Point3< Type2 > &point)
bool operator>=(const Point3 &p2) const
Definition: Point.h:258
void reset()
Reset values to default.
Definition: Point.h:146
Point2()
Constructor. Empty for fast points array allocation.
Definition: Point.h:42
static const int size_
Definition: Point.h:331
Point3< T > operator+(const T2 &val) const
Definition: Point.h:224
bool operator<=(const Point4 &p2) const
Definition: Point.h:423
Point3< T > operator-(const T2 &val) const
Definition: Point.h:226
T distanceSquare(const Point2< T > &p1, const Point2< T > &p2)
Distance measure (squared)
Definition: Point.h:165
Point3 & operator=(const Point4< T > &ot)
Definition: Point.h:212
Point3 & operator-=(const Point3 &ot)
Definition: Point.h:237
Point4< float > Point4F
Definition: Point.h:510
Point4(T tx, T ty, T tz, T tw)
Definition: Point.h:364
Point2< T > & operator+=(const T2 &val)
Definition: Point.h:65
Point3< int > Point3I
Definition: Point.h:505
Point2(T tx, T ty)
Definition: Point.h:44
Point4 operator+(const Point4 &p2) const
Definition: Point.h:407
static const int size_
Definition: Point.h:161
Point2 & operator*=(const Point2 &ot)
Definition: Point.h:84
double lengthSquared() const
Square of length of point.
Definition: Point.h:440
Point3(const Point3 &ot)
Copying constructor.
Definition: Point.h:201
bool operator!=(const Point4 &p2) const
Definition: Point.h:419
Point2 operator+(const Point2 &p2) const
Definition: Point.h:87
bool operator>(const Point2 &p2) const
Definition: Point.h:100
void normalize()
normalizing to unit vector in euclidean norm
Definition: Point.h:443
Point2< double > Point2D
Definition: Point.h:503
Point2 & operator=(const Point3< T > &ot)
Definition: Point.h:54
Point3(const Point3< T2 > &ot)
Type conversion.
Definition: Point.h:215
Point4 & operator=(const Point2< T > &ot)
Definition: Point.h:374
bool operator<=(const Point3 &p2) const
Definition: Point.h:263
void normalize()
normalizing to unit vector in euclidean norm
Definition: Point.h:292
Point3< double > Point3D
Definition: Point.h:507
bool operator>(const Point3 &p2) const
Definition: Point.h:257
Point4 & operator/=(const Point4 &ot)
Definition: Point.h:405
Point4< T > & operator-=(const T2 &val)
Definition: Point.h:386
bool operator<=(const Point2 &p2) const
Definition: Point.h:103
Point3 normalized() const
Definition: Point.h:303
Point3< T > crossProduct(const Point3< T > &p1, const Point3< T > &p2)
Cross product of two points.
Definition: Point.h:347
Point2 & operator=(const Point4< T > &ot)
Definition: Point.h:58
Point3 operator-() const
Unary minus.
Definition: Point.h:248
Point4< T > operator-(const T2 &val) const
Definition: Point.h:392
Point4 operator*(const Point4 &p2) const
Definition: Point.h:409
Point4 operator-() const
Unary minus.
Definition: Point.h:414
Point4< T > & operator*=(const T2 &val)
Definition: Point.h:387
Point2 operator/(const Point2 &p2) const
Definition: Point.h:90
Point2< T > operator-(const T2 &val) const
Definition: Point.h:72
Point4 & operator*=(const Point4 &ot)
Definition: Point.h:404
Point2 & operator+=(const Point2 &ot)
Definition: Point.h:82
Point2(const Point2 &ot)
Copying constructor.
Definition: Point.h:47
Point3< T > & operator+=(const T2 &val)
Definition: Point.h:219
Point4(const Point4< T2 > &ot)
Type conversion.
Definition: Point.h:381
Point3< T > & operator*=(const T2 &val)
Definition: Point.h:221
void normalize()
normalizing to unit vector in euclidean norm
Definition: Point.h:123
static T dot(const Point4< T > &p1, const Point4< T > &p2)
Inner product operator.
Definition: Point.h:427
Point2(const Point4< T > &ot)
Point4 conversion.
Definition: Point.h:57
Point3 & operator/=(const Point3 &ot)
Definition: Point.h:239
Point4< T > & operator+=(const T2 &val)
Definition: Point.h:385
Point4()
Constructor. Empty for fast points array allocation.
Definition: Point.h:362
Point3(const Point2< T > &ot)
Point2 conversion.
Definition: Point.h:207
Point4 & operator=(const Point4 &ot)
Assignment operator.
Definition: Point.h:370
double length() const
Length of point.
Definition: Point.h:437
Point4< T > operator*(const T2 &val) const
Definition: Point.h:394
bool operator==(const Point2 &p2) const
Definition: Point.h:98
Point2< T > operator-(const T2 &val, const Point2< T > &p)
Definition: Point.h:180
Point4 & operator+=(const Point4 &ot)
Definition: Point.h:402
Point4 operator-(const Point4 &p2) const
Definition: Point.h:408
static T dot(const Point2< T > &p1, const Point2< T > &p2)
Inner product operator.
Definition: Point.h:107
bool operator==(const Point4 &p2) const
Definition: Point.h:418
Point2< int > Point2I
Definition: Point.h:501
Point3< T > operator*(const T2 &val) const
Definition: Point.h:228
Point4< T > & operator/=(const T2 &val)
Definition: Point.h:388
static T dot(const Point3< T > &p1, const Point3< T > &p2)
Inner product operator.
Definition: Point.h:270
Point3 operator/(const Point3 &p2) const
Definition: Point.h:244
bool operator>=(const Point2 &p2) const
Definition: Point.h:101
T dotProduct(const Point2< T > &p1, const Point2< T > &p2)
Cross product of two points.
Definition: Point.h:171
Point4(const Point4 &ot)
Copying constructor.
Definition: Point.h:367
void reset()
Reset values to default.
Definition: Point.h:468
Point3< float > Point3F
Definition: Point.h:506
void reset()
Reset values to default.
Definition: Point.h:316
Point2 & operator=(const Point2 &ot)
Assignment operator.
Definition: Point.h:50
bool operator!=(const Point3 &p2) const
Definition: Point.h:256
bool isZero() const
Zero checking.
Definition: Point.h:465
Point3< T > operator/(const T2 &val) const
Definition: Point.h:230
Point3 & operator+=(const Point3 &ot)
Definition: Point.h:236
Point4< T > operator/(const T2 &val) const
Definition: Point.h:396
Point3 & operator=(const Point3 &ot)
Assignment operator.
Definition: Point.h:204
static Point3< T > cross(const Point3< T > &p1, const Point3< T > &p2)
Cross product of two points.
Definition: Point.h:276
bool isZero() const
Zero checking.
Definition: Point.h:313
bool isZero(const Tf &some)
Equality expression for types which are not exact.
Definition: Point.h:25
Point2 & operator-=(const Point2 &ot)
Definition: Point.h:83
Point3(T tx, T ty, T tz)
Definition: Point.h:198
Point4 & operator-=(const Point4 &ot)
Definition: Point.h:403
Point2< float > Point2F
Definition: Point.h:502
Point3 & operator=(const Point2< T > &ot)
Definition: Point.h:208
Point3()
Constructor. Empty for fast points array allocation.
Definition: Point.h:196
Point4(const Point2< T > &ot)
Point2 conversion.
Definition: Point.h:373
static const int size_
Definition: Point.h:483
Point4< int > Point4I
Definition: Point.h:509
double lengthSquared() const
Square of length of point.
Definition: Point.h:120
Point4< double > Point4D
Definition: Point.h:511
Point2< T > operator+(const T2 &val) const
Definition: Point.h:70
Point4(const Point3< T > &ot)
Point3 conversion.
Definition: Point.h:377
Point2(const Point2< T2 > &ot)
Type conversion.
Definition: Point.h:61
Point2 operator*(const Point2 &p2) const
Definition: Point.h:89
bool operator!=(const Point2 &p2) const
Definition: Point.h:99
Point2< T > & operator-=(const T2 &val)
Definition: Point.h:66
Point2 operator-(const Point2 &p2) const
Definition: Point.h:88
Point2< T > & operator/=(const T2 &val)
Definition: Point.h:68
Point2< T > operator/(const T2 &val) const
Definition: Point.h:76
Point2< T > & operator*=(const T2 &val)
Definition: Point.h:67
Point2 & operator/=(const Point2 &ot)
Definition: Point.h:85
Point3 operator+(const Point3 &p2) const
Definition: Point.h:241
double length() const
Length of point.
Definition: Point.h:117
Point3< T > & operator-=(const T2 &val)
Definition: Point.h:220
Point4 operator/(const Point4 &p2) const
Definition: Point.h:410
double length() const
Length of point.
Definition: Point.h:286