19 vetCoord[0]=vetCoord[1]=vetCoord[2]=0;
25 vetCoord[0] = point.vetCoord[0];
26 vetCoord[1] = point.vetCoord[1];
27 vetCoord[2] = point.vetCoord[2];
28 vetCoord[3] = point.vetCoord[3];
94 double norma = Length();
104 vetCoord[0] /= vetCoord[3];
105 vetCoord[1] /= vetCoord[3];
106 vetCoord[2] /= vetCoord[3];
113 return sqrt(vetCoord[0]*vetCoord[0] + vetCoord[1]*vetCoord[1] + vetCoord[2]*vetCoord[2]);
118 return vetCoord[0]*p.vetCoord[0]+vetCoord[1]*p.vetCoord[1]+vetCoord[2]*p.vetCoord[2];
129 double dp = DotProduct(p);
136 return 3.1415926535897932384626433832795;
144 double absoluteValue = AngleTo(p);
145 Point4D crossProduct = CrossProduct(p);
146 if (ref.AlmostEqual(crossProduct))
147 return absoluteValue;
149 return -absoluteValue;
155 double cosValue = DotProduct(p) / (Length()*p.
Length());
161 return 3.1415926535897932384626433832795;
162 return acos(cosValue);
170 return VART::Point4D(-vetCoord[0], -vetCoord[1], -vetCoord[2], vetCoord[3]);
176 vetCoord[1]-point.vetCoord[1],
177 vetCoord[2]-point.vetCoord[2],
178 vetCoord[3]-point.vetCoord[3]);
188 vetCoord[1]+vector.vetCoord[1],
189 vetCoord[2]+vector.vetCoord[2],
190 vetCoord[3]+vector.vetCoord[3]);
196 vetCoord[0] += vector.vetCoord[0];
197 vetCoord[1] += vector.vetCoord[1];
198 vetCoord[2] += vector.vetCoord[2];
206 vetCoord[3]*escalar);
211 vetCoord[0]*=escalar;
212 vetCoord[1]*=escalar;
213 vetCoord[2]*=escalar;
214 vetCoord[3]*=escalar;
219 return (vetCoord[0] == point.vetCoord[0]) &&
220 (vetCoord[1] == point.vetCoord[1]) &&
221 (vetCoord[2] == point.vetCoord[2]) &&
222 (vetCoord[3] == point.vetCoord[3]);
227 return (this->*operatorLess)(p);
232 return (vetCoord[0] != point.vetCoord[0]) ||
233 (vetCoord[1] != point.vetCoord[1]) ||
234 (vetCoord[2] != point.vetCoord[2]) ||
235 (vetCoord[3] != point.vetCoord[3]);
240 vetCoord[0] = point.vetCoord[0];
241 vetCoord[1] = point.vetCoord[1];
242 vetCoord[2] = point.vetCoord[2];
243 vetCoord[3] = point.vetCoord[3];
251 vetCoord[3]/escalar);
256 if (vetCoord[0] == p.vetCoord[0])
258 if (vetCoord[1] == p.vetCoord[1])
260 if (vetCoord[2] == p.vetCoord[2])
261 return vetCoord[3] < p.vetCoord[3];
263 return vetCoord[2] < p.vetCoord[2];
266 return vetCoord[1] < p.vetCoord[1];
269 return vetCoord[0] < p.vetCoord[0];
274 if (vetCoord[0] == p.vetCoord[0])
275 return vetCoord[2] < p.vetCoord[2];
277 return vetCoord[0] < p.vetCoord[0];
282 if (vetCoord[1] == p.vetCoord[1])
283 return vetCoord[0] < p.vetCoord[0];
285 return vetCoord[1] < p.vetCoord[1];
290 if (vetCoord[1] == p.vetCoord[1])
291 return vetCoord[2] < p.vetCoord[2];
293 return vetCoord[1] < p.vetCoord[1];
298 if (vetCoord[2] == p.vetCoord[2])
299 return vetCoord[0] < p.vetCoord[0];
301 return vetCoord[2] < p.vetCoord[2];
306 if (vetCoord[2] == p.vetCoord[2])
307 return vetCoord[1] < p.vetCoord[1];
309 return vetCoord[2] < p.vetCoord[2];
314 return WeightedSum() < p.WeightedSum();
319 return WeightedSum() > p.WeightedSum();
322 float VART::Point4D::WeightedSum()
const
324 return (vetCoord[0] * xWeight) + (vetCoord[1] * yWeight) + (vetCoord[2] * zWeight);
329 return abs( vetCoord[0] - v.vetCoord[0]
330 + vetCoord[1] - v.vetCoord[1]
331 + vetCoord[2] - v.vetCoord[2] ) < delta;
338 output.setf(ios::fixed);
340 output <<
"(" << p.
GetX() <<
"," << p.
GetY() <<
"," << p.
GetZ() <<
","
342 output.unsetf(ios::fixed);
double AngleTo(const Point4D &p) const
Computes the angle up to p.
bool ZThenXLess(const Point4D &p) const
Points and vectors using homogeneous coordinates.
double Length() const
Returns the vector's length.
static tCompareOper operatorLess
Points to the operator to use within operator<.
static const Point4D & Y()
The Y vector (0,1,0,0).
Point4D operator-() const
void operator*=(double escalar)
void Normalize()
Normalizes the point/vector.
static float yWeight
Weight of the Y coordinate for Weighted comparisons.
Point4D operator+(const Point4D &vector) const
Addition for point and vector (or vice versa).
static const Point4D & Z()
The Z vector (0,0,1,0).
bool YThenZLess(const Point4D &p) const
Point4D operator/(double escalar) const
bool LexicographicalLess(const Point4D &p) const
Verifies whether a point is less than other by looking at coordinates in lexicographical (x...
Point4D CrossProduct(const Point4D &p) const
Computes the cross product between "this" and "p".
void SetXYZ(double x, double y, double z)
bool WeightedLess(const Point4D &p) const
static float xWeight
Weight of the X coordinate for Weighted comparisons.
bool operator!=(const Point4D &point) const
bool operator==(const Point4D &point) const
bool XThenZLess(const Point4D &p) const
Verifies whether a point is less then other by looking at coordinates X, then Z only.
void operator=(const Point4D &point)
static const Point4D & X()
The X vector (1,0,0,0).
static float zWeight
Weight of the Z coordinate for Weighted comparisons.
static const Point4D & DOWN()
The (0,-1,0,0) vector.
bool operator<(const Point4D &p) const
Checks whether a point is "less then" other.
static double delta
Maximum difference for equality.
bool AlmostEqual(const Point4D &v) const
Check if vector is almost equal to some other vector.
bool ZThenYLess(const Point4D &p) const
static const Point4D & ORIGIN()
The (0,0,0,1) point.
void SetXYZW(double x, double y, double z, double w)
Header file for V-ART class "Point4D".
double DotProduct(const Point4D &p) const
Computes the dot product between "this" and "p".
ostream & operator<<(ostream &output, const Point4D &p)
bool YThenXLess(const Point4D &p) const
void operator+=(const Point4D &vector)
Point4D operator*(double escalar) const
Point4D()
Creates the (0,0,0,1) point.
void SetXY(double x, double y)
bool WeightedGreater(const Point4D &p) const
double GenericAngleTo(const Point4D &p) const