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