Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HomgPoint1D.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #ifndef _HomgPoint1D_hh_
27 #define _HomgPoint1D_hh_
28 #include "bias_config.h"
29 
30 #include <Base/Debug/Error.hh>
31 #include <Base/Math/Vector2.hh>
32 
33 
34 
35 // the type of each element:
36 #define HOMGPOINT1D_TYPE double
37 // values whose abs is < epsilon are handled as zero
38 #define HOMGPOINT1D_TYPE_EPS 1E-12
39 
40 namespace BIAS {
41 
42  /** @class HomgPoint1D
43  @brief class HomgPoint1D describes a point with 2 degrees of freedom in
44  projective coordinates.
45 
46  manual loop unrolling is used if possible.
47  The Vector is in row-major order (3 rows, 1 column)
48  the indizes begin with zero (to size-1)
49 
50  constructors and assignment operators are never inherited, so they are
51  wrapped (or reimplemented) here.
52  @author Jan Woetzel
53  @status untested (03/04/2002)
54  **/
55  // all inline - nothing to compile
56  class /*BIASGeometryBase_EXPORT*/ HomgPoint1D
57  : public Vector2 < HOMGPOINT1D_TYPE > {
58 
59  public:
60 
61  /** destructor
62  @author Jan Woetzel
63  @status untested (02/28/2002)
64  **/
66  ;
67 
68 
69  /** default constructor
70  @author Jan Woetzel
71  @status untested (02/28/2002)
72  **/
73  inline HomgPoint1D():Vector2 < HOMGPOINT1D_TYPE > () {}
74  ;
75 
76  /** copy constructor
77  @author Jan Woetzel
78  @status untested (03/05/2002)
79  **/
80  inline HomgPoint1D(const HomgPoint1D & p):Vector2 < HOMGPOINT1D_TYPE >
81  (p) {}
82  ;
83 
84 
85  /** assignment with a constant value for all elements
86  @author Jan Woetzel
87  @status untested (03/01/2002) **/
88  explicit inline HomgPoint1D(const HOMGPOINT1D_TYPE & scalar):Vector2 <
89  HOMGPOINT1D_TYPE > (scalar) {}
90  ;
91 
92  /** assignment with an array of values
93  which is copied into this ones class members
94  @author Jan Woetzel
95  @status untested (02/28/2002) **/
96  explicit inline HomgPoint1D(const HOMGPOINT1D_TYPE * pv):Vector2 <
97  HOMGPOINT1D_TYPE > (pv) {}
98  ;
99 
100  /** assignment with 3 values
101  which is copied into this ones class members
102  @author Arne Petersen
103  @status untested (07/2008) **/
104  explicit inline HomgPoint1D(const HOMGPOINT1D_TYPE &v1,
105  const HOMGPOINT1D_TYPE &v2)
106  :Vector2 <HOMGPOINT1D_TYPE > ()
107  {
108  data_[0] = v1; data_[1] = v2;
109  };
110 
111  /** constructor with element assignment
112  @author Jan Woetzel
113  @status untested (03/01/2002) **/
114  explicit inline HomgPoint1D(char *s):Vector2 < HOMGPOINT1D_TYPE > (s) {}
115  ;
116 
117  /** assignment operator
118  set the elements of this HomgPoint to the element of vec
119  @author Jan Woetzel
120  @status untested (02/25/2002)
121  **/
122  inline HomgPoint1D & operator =
124  // copy the elements of vec to this HomgPoint coordinates
125  Copy(vec.GetData());
126  return *this;
127  };
128 
129  /** assignment operator
130  set the vector elementwise to scalar value
131  @author Jan Woetzel
132  @status untested (02/28/2002)
133  **/
134  inline HomgPoint1D & operator = (const HOMGPOINT1D_TYPE & scalar) {
135  Set(scalar);
136  return *this;
137  };
138 
139 
140  /** homogenize class data member elements to W==1 by divison by W
141  @author Jan Woetzel
142  @status untested (02/28/2002)
143  **/
144  inline void Homogenize() {
145  // w = data_[3] is not in [-eps..eps] (means non-zero)
146  BIASASSERT(!((GetW() > -1 * HOMGPOINT1D_TYPE_EPS)
147  && (GetW() < HOMGPOINT1D_TYPE_EPS)));
148  data_[0] = data_[0] / GetW();
149  data_[1] = data_[1] / GetW(); // should be 1
150  };
151 
152  /** return the euclidean coordinates
153  Only possible for w !=0 because w==0 describes points of infinity
154  which are not in euclidean space (but may be interpreted as directions)
155  @author Jan Woetzel
156  @status untested (03/04/2002)
157  **/
158  inline HOMGPOINT1D_TYPE GetEuclidean() const {
159  // Test if w is zero (within epsilon environment)
160  BIASASSERT(!((GetW() > -1 * HOMGPOINT1D_TYPE_EPS) &&
161  (GetW() < HOMGPOINT1D_TYPE_EPS)));
162  return (GetX() / GetW());
163  };
164 
165  // deprecated version
166  inline HOMGPOINT1D_TYPE GetEuclidian() const {
167  return this->GetEuclidean();
168  };
169 
170  ////////////////////////////////////////////////////////////////////////
171  ///////////////// Comparison operators /////////////////////////////////
172  ////////////////////////////////////////////////////////////////////////
173 
174 
175  /** Comparison operator 'equal'
176  @author Arne Petersen
177  @status untested
178  **/
179  inline bool operator== (const HomgPoint1D& arg) const {
180  //If w!=0 for 'this' and 'arg' this is equivalent to first homogenize
181  //the points and then test vectors for equality.
182  //If w==0 for 'this' xor 'arg' this results in false (as it should).
183  //If w==0 for 'this' and 'arg' this results in true, because
184  //there's only one point at infinity!
185  return (data_[0]*arg[1] == data_[1]*arg[0]);
186  }
187 
188  /** Comparison operator 'not equal'
189  @author Ingo Thomsen
190  @status tested
191  **/
192  inline bool operator!= (const HomgPoint1D& arg) const {
193  return !(*this == arg);
194  }
195 
196 
197 
198  }
199  ; // class HomgPoint1D ------------------------------------------
200 } // namespace BIAS
201 #endif
202 // ///////////// do not add code after this line ! /////////////
void Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint1D.hh:144
HOMGPOINT1D_TYPE & GetW()
Definition: Vector2.hh:295
HOMGPOINT1D_TYPE GetEuclidian() const
Definition: HomgPoint1D.hh:166
HomgPoint1D(const HOMGPOINT1D_TYPE &v1, const HOMGPOINT1D_TYPE &v2)
assignment with 3 values which is copied into this ones class members
Definition: HomgPoint1D.hh:104
class Vector2 contains a Vector of dim.
Definition: Vector2.hh:79
HomgPoint1D(char *s)
constructor with element assignment
Definition: HomgPoint1D.hh:114
~HomgPoint1D()
destructor
Definition: HomgPoint1D.hh:65
HomgPoint1D(const HOMGPOINT1D_TYPE *pv)
assignment with an array of values which is copied into this ones class members
Definition: HomgPoint1D.hh:96
void Set(const HOMGPOINT1D_TYPE &scalar)
set all elements to a scalar value
Definition: Vector2.hh:190
HomgPoint1D(const HOMGPOINT1D_TYPE &scalar)
assignment with a constant value for all elements
Definition: HomgPoint1D.hh:88
HOMGPOINT1D_TYPE data_[VECTOR2SIZE]
Definition: Vector2.hh:677
HOMGPOINT1D_TYPE & GetX()
read only access functions to use names instead of indizes
Definition: Vector2.hh:289
bool operator!=(const HomgPoint1D &arg) const
Comparison operator &#39;not equal&#39;.
Definition: HomgPoint1D.hh:192
HomgPoint1D & operator=(const Vector2< HOMGPOINT1D_TYPE > &vec)
assignment operator set the elements of this HomgPoint to the element of vec
Definition: HomgPoint1D.hh:123
bool operator==(const HomgPoint1D &arg) const
Comparison operator &#39;equal&#39;.
Definition: HomgPoint1D.hh:179
class HomgPoint1D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint1D.hh:56
HomgPoint1D(const HomgPoint1D &p)
copy constructor
Definition: HomgPoint1D.hh:80
HOMGPOINT1D_TYPE GetEuclidean() const
return the euclidean coordinates Only possible for w !=0 because w==0 describes points of infinity wh...
Definition: HomgPoint1D.hh:158
void Copy(const HOMGPOINT1D_TYPE *pv)
copy the array of vectorsize beginning at *T to this-&gt;data_
Definition: Vector2.hh:180
HomgPoint1D()
default constructor
Definition: HomgPoint1D.hh:73