26 #ifndef _HomgPoint3D_hh_
27 #define _HomgPoint3D_hh_
28 #include "bias_config.h"
30 #include <Base/Debug/Error.hh>
31 #include <Base/Math/Vector4.hh>
32 #include <Base/Math/Vector3.hh>
35 #define HOMGPOINT3D_TYPE double
36 #define HOMGPOINT3D_EPS 1E-12
37 #define HOMGPOINT3D_TYPE_INF std::numeric_limits<double>::infinity()
68 :
Vector4<HOMGPOINT3D_TYPE>(p) {};
71 :
Vector4<HOMGPOINT3D_TYPE>(p) {};
81 :
Vector4<HOMGPOINT3D_TYPE>(scalar) {};
88 :
Vector4<HOMGPOINT3D_TYPE>(pv) {};
94 :
Vector4<HOMGPOINT3D_TYPE>(s) {};
101 const HOMGPOINT3D_TYPE & y,
102 const HOMGPOINT3D_TYPE & z);
113 const HOMGPOINT3D_TYPE & y,
114 const HOMGPOINT3D_TYPE & z,
115 const HOMGPOINT3D_TYPE & w)
116 :
Vector4<HOMGPOINT3D_TYPE>(x, y, z, w) {};
118 inline bool IsAtInfinity()
const;
120 inline HOMGPOINT3D_TYPE GetX()
const;
121 inline HOMGPOINT3D_TYPE GetY()
const;
122 inline HOMGPOINT3D_TYPE GetZ()
const;
123 inline HOMGPOINT3D_TYPE GetW()
const;
124 inline HOMGPOINT3D_TYPE GetW();
138 inline HomgPoint3D& operator=(
const HOMGPOINT3D_TYPE& scalar);
144 inline void Homogenize();
148 return data_[3]<1.0+HOMGPOINT3D_EPS &&
149 data_[3]>1.0-HOMGPOINT3D_EPS;
156 inline void Set(
const HOMGPOINT3D_TYPE& x,
const HOMGPOINT3D_TYPE& y,
157 const HOMGPOINT3D_TYPE& z);
161 inline void Set(
const HOMGPOINT3D_TYPE& x,
const HOMGPOINT3D_TYPE& y,
162 const HOMGPOINT3D_TYPE& z,
const HOMGPOINT3D_TYPE& w)
177 this->GetEuclidean(dest);
180 return this->GetEuclidean();
189 inline HOMGPOINT3D_TYPE GetEuclideanX()
const;
190 inline HOMGPOINT3D_TYPE GetEuclideanY()
const;
191 inline HOMGPOINT3D_TYPE GetEuclideanZ()
const;
194 return this->GetEuclideanX();
197 return this->GetEuclideanY();
200 return this->GetEuclideanZ();
206 inline bool operator==(
const HomgPoint3D& arg)
const;
211 inline bool operator!=(
const HomgPoint3D& arg)
const;
213 inline HOMGPOINT3D_TYPE Distance(
const HomgPoint3D& point)
const;
226 const HOMGPOINT3D_TYPE & y,
227 const HOMGPOINT3D_TYPE & z)
252 if (
data_[3] > -HOMGPOINT3D_EPS &&
data_[3] < HOMGPOINT3D_EPS)
259 if (
data_[3] > -HOMGPOINT3D_EPS &&
data_[3] < HOMGPOINT3D_EPS)
298 for (
int i=0;i<vec.
size();i++)
302 BIASERR(
"Initialization of HomgPoint3D from Vector with length"
303 <<
"!= 3 or !=4,length is " << vec.
size());
310 HOMGPOINT3D_TYPE w =
GetW();
311 if (fabs(w) > HOMGPOINT3D_EPS){
317 BEXCEPTION(
"cannot homogenize, w is zero: "<<w);
322 const HOMGPOINT3D_TYPE & y,
323 const HOMGPOINT3D_TYPE & z)
338 HOMGPOINT3D_TYPE w =
GetW();
340 dest[0] =
data_[0] / w;
341 dest[1] =
data_[1] / w;
342 dest[2] =
data_[2] / w;
359 HOMGPOINT3D_TYPE w =
GetW();
360 BIASASSERT(w != 0.0);
361 return (
data_[0] / w);
366 HOMGPOINT3D_TYPE w =
GetW();
367 BIASASSERT(w != 0.0);
368 return (
data_[1] / w);
373 HOMGPOINT3D_TYPE w =
GetW();
374 BIASASSERT(w != 0.0);
375 return (
data_[2] / w);
381 bool res = (
data_[0]*arg[3] ==
data_[3]*arg[0])
385 if ((
data_[3]!=0.0)||(arg[3]!=0.0))
return res;
395 return !(*
this == arg);
400 return (
data_[3] > -HOMGPOINT3D_EPS &&
data_[3] < HOMGPOINT3D_EPS);
403 inline HOMGPOINT3D_TYPE
406 if ((
data_[3] > -HOMGPOINT3D_EPS &&
data_[3] < HOMGPOINT3D_EPS) ||
407 (point[3] > -HOMGPOINT3D_EPS && point[3] < HOMGPOINT3D_EPS)) {
408 return HOMGPOINT3D_TYPE_INF;
410 HOMGPOINT3D_TYPE dx=
data_[0]/
data_[3] - point[0]/point[3];
411 HOMGPOINT3D_TYPE dy=
data_[1]/
data_[3] - point[1]/point[3];
412 HOMGPOINT3D_TYPE dz=
data_[2]/
data_[3] - point[2]/point[3];
413 return sqrt(dx*dx + dy*dy + dz*dz);
HOMGPOINT3D_TYPE GetX() const
HOMGPOINT3D_TYPE GetEuclidianY() const
bool operator==(const HomgPoint3D &arg) const
Comparison operator 'equal'.
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z)
set elementwise with given 3 euclidean scalar values.
void Homogenize()
homogenize class data member elements to W==1 by divison by W
void Set(const T &scalar)
set all elements to a scalat value
HOMGPOINT3D_TYPE GetEuclideanX() const
return the euclidean coordinates Only possible for w !=0 because w==0 describes points of infinity wh...
HOMGPOINT3D_TYPE GetW() const
HomgPoint3D(const HOMGPOINT3D_TYPE &scalar)
assignment with a constant value for all elements
HomgPoint3D(const HOMGPOINT3D_TYPE *pv)
assignment with an array of values which is copied into this ones class members
class Vector4 contains a Vector of dim.
Vector3< HOMGPOINT3D_TYPE > GetEuclidian() const
HOMGPOINT3D_TYPE data_[VECTOR4SIZE]
void Copy(const HOMGPOINT3D_TYPE *pv)
copy the array of vectorsize beginning at *T to this->data_
bool operator!=(const HomgPoint3D &arg) const
Comparison operator 'not equal'.
HomgPoint3D(const HomgPoint3D &p)
HOMGPOINT3D_TYPE Distance(const HomgPoint3D &point) const
bool IsAtInfinity() const
void Set(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z, const HOMGPOINT3D_TYPE &w)
set elementwise
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
class Vector3 contains a Vector of fixed dim.
HOMGPOINT3D_TYPE GetEuclideanZ() const
const T * GetData() const
get the data pointer the member function itself is const (before {..}) because it doesn't change the...
HomgPoint3D & operator=(const Vector4< HOMGPOINT3D_TYPE > &vec)
assignment operator set the elements of this HomgPoint to the element of vec
Vector3< HOMGPOINT3D_TYPE > GetEuclidean() const
HOMGPOINT3D_TYPE GetEuclidianZ() const
HOMGPOINT3D_TYPE GetEuclidianX() const
deprecated versions
HOMGPOINT3D_TYPE GetY() const
void GetEuclidian(Vector3< HOMGPOINT3D_TYPE > &dest) const
deprecated versions
bool IsHomogenized() const
HomgPoint3D(const HOMGPOINT3D_TYPE &x, const HOMGPOINT3D_TYPE &y, const HOMGPOINT3D_TYPE &z, const HOMGPOINT3D_TYPE &w)
HomgPoint3D(const Vector4< HOMGPOINT3D_TYPE > &p)
HOMGPOINT3D_TYPE GetEuclideanY() const
HOMGPOINT3D_TYPE GetZ() const
class BIASGeometryBase_EXPORT HomgPoint3D
HomgPoint3D(char *s)
constructor with element assignment