V-ART
point4d.h
Go to the documentation of this file.
1 
5 #ifndef VART_POINT4D_H
6 #define VART_POINT4D_H
7 
8 #include "vart/point.h" // FixMe: remove this later.
9 #include <iostream>
10 
11 namespace VART {
22  class Point4D : public Point {
24  // FixMe: Perhaps this will cause trouble on an application with no console...
25  friend std::ostream& operator<<(std::ostream& output, const Point4D& p);
26 
28  typedef bool (Point4D::*tCompareOper)(const Point4D&) const;
29  public:
30  // PUBLIC METHODS
32  Point4D();
33  Point4D(const Point4D& point);
34  Point4D(double x, double y, double z, double w = 1.0);
35 
36  Point4D operator-() const;
37  bool operator==(const Point4D& point) const;
38  bool operator!=(const Point4D& point) const;
39  void operator=(const Point4D& point);
40 
45  bool operator<(const Point4D& p) const;
46 
49  bool LexicographicalLess(const Point4D& p) const;
50 
53  bool XThenZLess(const Point4D& p) const;
54  bool YThenXLess(const Point4D& p) const;
55  bool YThenZLess(const Point4D& p) const;
56  bool ZThenXLess(const Point4D& p) const;
57  bool ZThenYLess(const Point4D& p) const;
58  bool WeightedLess(const Point4D& p) const;
59  bool WeightedGreater(const Point4D& p) const;
60 
65  Point4D operator+(const Point4D& vector) const;
66  void operator+=(const Point4D& vector);
67 
72  Point4D operator-(const Point4D& point) const;
73  Point4D operator*(double escalar) const;
74  void operator*=(double escalar);
75 
76  Point4D operator/( double escalar ) const;
77 
78  double GetX() const { return vetCoord[0]; }
79  double GetY() const { return vetCoord[1]; }
80  double GetZ() const { return vetCoord[2]; }
81  double GetW() const { return vetCoord[3]; }
82 
86  const double* VetXYZW() const { return vetCoord; }
87 
89  double DotProduct(const Point4D& p) const;
90 
96  double AngleTo(const Point4D& p) const;
97 
102  double AngleTo(const Point4D& p, const Point4D& ref) const;
103 
107  double GenericAngleTo(const Point4D& p) const;
108 
110  Point4D CrossProduct(const Point4D& p) const;
111 
112  void SetX(double x) { vetCoord[0] = x; }
113  void SetY(double y) { vetCoord[1] = y; }
114  void SetZ(double z) { vetCoord[2] = z; }
115  void SetW(double w) { vetCoord[3] = w; }
116  void SetXY(double x, double y);
117  void SetXYZ(double x, double y, double z);
118  void SetXYZW(double x, double y, double z, double w);
119 
126  void Normalize();
127 
129  double Length() const;
130 
132  bool AlmostEqual(const Point4D& v) const;
133 
134  // PUBLIC STATIC METHODS
136  static const Point4D& DOWN();
138  static const Point4D& ORIGIN();
140  static const Point4D& X();
142  static const Point4D& Y();
144  static const Point4D& Z();
145  // PUBLIC STATIC ATTRIBUTES
152  static tCompareOper operatorLess;
153 
155  static float xWeight;
157  static float yWeight;
159  static float zWeight;
163  static double delta;
164  private:
165  double vetCoord[4];
166  float WeightedSum() const;
167  }; // end class declaration
168 } // end namespace
169 #endif
double AngleTo(const Point4D &p) const
Computes the angle up to p.
Definition: point4d.cpp:126
bool ZThenXLess(const Point4D &p) const
Definition: point4d.cpp:296
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
double Length() const
Returns the vector's length.
Definition: point4d.cpp:111
static tCompareOper operatorLess
Points to the operator to use within operator<.
Definition: point4d.h:152
static const Point4D & Y()
The Y vector (0,1,0,0).
Definition: point4d.cpp:43
void SetW(double w)
Definition: point4d.h:115
friend std::ostream & operator<<(std::ostream &output, const Point4D &p)
Output operator.
Point4D operator-() const
Definition: point4d.cpp:166
Header file for V-ART class "Point".
void operator*=(double escalar)
Definition: point4d.cpp:209
void Normalize()
Normalizes the point/vector.
Definition: point4d.cpp:88
double GetZ() const
Definition: point4d.h:80
static float yWeight
Weight of the Y coordinate for Weighted comparisons.
Definition: point4d.h:157
Point4D operator+(const Point4D &vector) const
Addition for point and vector (or vice versa).
Definition: point4d.cpp:181
double GetY() const
Definition: point4d.h:79
static const Point4D & Z()
The Z vector (0,0,1,0).
Definition: point4d.cpp:49
bool YThenZLess(const Point4D &p) const
Definition: point4d.cpp:288
void SetX(double x)
Definition: point4d.h:112
Point4D operator/(double escalar) const
Definition: point4d.cpp:246
bool LexicographicalLess(const Point4D &p) const
Verifies whether a point is less than other by looking at coordinates in lexicographical (x...
Definition: point4d.cpp:254
Point4D CrossProduct(const Point4D &p) const
Computes the cross product between "this" and "p".
Definition: point4d.cpp:121
void SetXYZ(double x, double y, double z)
Definition: point4d.cpp:73
bool WeightedLess(const Point4D &p) const
Definition: point4d.cpp:312
static float xWeight
Weight of the X coordinate for Weighted comparisons.
Definition: point4d.h:155
bool operator!=(const Point4D &point) const
Definition: point4d.cpp:230
bool operator==(const Point4D &point) const
Definition: point4d.cpp:217
bool XThenZLess(const Point4D &p) const
Verifies whether a point is less then other by looking at coordinates X, then Z only.
Definition: point4d.cpp:272
void operator=(const Point4D &point)
Definition: point4d.cpp:238
static const Point4D & X()
The X vector (1,0,0,0).
Definition: point4d.cpp:37
static float zWeight
Weight of the Z coordinate for Weighted comparisons.
Definition: point4d.h:159
void SetY(double y)
Definition: point4d.h:113
static const Point4D & DOWN()
The (0,-1,0,0) vector.
Definition: point4d.cpp:55
void SetZ(double z)
Definition: point4d.h:114
bool operator<(const Point4D &p) const
Checks whether a point is "less then" other.
Definition: point4d.cpp:225
static double delta
Maximum difference for equality.
Definition: point4d.h:163
bool AlmostEqual(const Point4D &v) const
Check if vector is almost equal to some other vector.
Definition: point4d.cpp:327
bool ZThenYLess(const Point4D &p) const
Definition: point4d.cpp:304
static const Point4D & ORIGIN()
The (0,0,0,1) point.
Definition: point4d.cpp:61
void SetXYZW(double x, double y, double z, double w)
Definition: point4d.cpp:80
double DotProduct(const Point4D &p) const
Computes the dot product between "this" and "p".
Definition: point4d.cpp:116
Abstract class that provides a common base for point and vector classes.
Definition: point.h:13
const double * VetXYZW() const
Returns vertex coordinates as a pointer to 4 doubles.
Definition: point4d.h:86
double GetW() const
Definition: point4d.h:81
bool YThenXLess(const Point4D &p) const
Definition: point4d.cpp:280
void operator+=(const Point4D &vector)
Definition: point4d.cpp:193
Point4D operator*(double escalar) const
Definition: point4d.cpp:201
Point4D()
Creates the (0,0,0,1) point.
Definition: point4d.cpp:17
double GetX() const
Definition: point4d.h:78
void SetXY(double x, double y)
Definition: point4d.cpp:67
bool WeightedGreater(const Point4D &p) const
Definition: point4d.cpp:317
double GenericAngleTo(const Point4D &p) const
Definition: point4d.cpp:152