Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HomgPoint2D.cpp
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 #include "HomgPoint2D.hh"
27 #include <Base/Math/Matrix3x3.hh>
28 
29 using namespace BIAS;
30 using namespace std;
31 
32 ostream& operator<<(ostream& os, const enum HomgPoint2D::EPosition pos)
33 {
34  switch(pos){
35  case HomgPoint2D::TopLeft: os << "topleft"; break;
36  case HomgPoint2D::Top: os << "top"; break;
37  case HomgPoint2D::TopRight: os << "topright"; break;
38  case HomgPoint2D::Left: os << "left"; break;
39  case HomgPoint2D::Center: os << "center"; break;
40  case HomgPoint2D::Right: os << "right"; break;
41  case HomgPoint2D::BottomLeft: os << "bottomleft"; break;
42  case HomgPoint2D::Bottom: os << "bottom"; break;
43  case HomgPoint2D::BottomRight: os << "bottomright"; break;
44  case HomgPoint2D::Infinity: os << "infinity"; break;
45  case HomgPoint2D::InvalidPosition: os << "invalid"; break;
46  }
47  return os;
48 }
49 
52 {
53  register const HOMGPOINT2D_TYPE w = data_[2];
55  if (fabs(w)>HOMGPOINT2D_TYPE_EPS){
56  /** the jacobian of the Homogenize() function is either
57  | 1/w 0 -x/w^2 |
58  | 0 1/w -y/w^2 |
59  | 0 0 0 | */
60  J[0][0] = J[1][1] = 1.0/w;
61  HOMGPOINT2D_TYPE w2 = w*w;
62  J[0][2] = -data_[1]/w2;
63  J[1][2] = -data_[2]/w2;
64  } else {
65  /** or | 1 0 0 |
66  | 0 1 0 |
67  | 0 0 0 | */
68  J[0][0] = J[1][1] = 1.0;
69  }
70  cov = J * cov * J.Transpose();
71 
72  return Homogenize();
73 }
74 
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
HomgPoint2D & Homogenize()
homogenize class data member elements to W==1 by divison by W
Definition: HomgPoint2D.hh:215
is a &#39;fixed size&#39; quadratic matrix of dim.
Definition: Matrix.hh:54
std::ostream & operator<<(std::ostream &os, const Array2D< T > &arg)
Definition: Array2D.hh:260
Matrix3x3< T > Transpose() const
returns transposed matrix tested 12.06.2002
Definition: Matrix3x3.cpp:167