Developer documentation

homography.hpp
Go to the documentation of this file.
1 /*******************************************************************
2  * This file is part of the source code of realroot kernel.
3  * Author(s): B. Mourrain, GALAAD, INRIA
4  * A. Mantzaflaris, GALAAD, INRIA
5  ********************************************************************/
6 #ifndef realroot_homography_hpp
7 #define realroot_homography_hpp
8 //====================================================================
9 
10 #include <realroot/Interval.hpp>
11 
12 namespace mmx {
13 
14  // (ax + b)/(cx + d)
15  template<class real> struct homography
16  {
17  real a,b,c,d;
18 
19  homography(): a(1),b(0),c(0),d(1) {}
20  homography(const homography& H): a(H.a),b(H.b),c(H.c),d(H.d) {}
21  homography(const real& A, const real& B, const real& C, const real&D): a(A),b(B),c(C),d(D) {}
22 
23  void shift_hom (const real & t ) { b+=t*a; d+=t*c; }
24 
25  // reciprocal_hom: t currently unused
26  void reciprocal_hom(const real & t )
27  { std::swap(a,b); std::swap(c,d); }
28 
29  void contract_hom (const real & t ) { a*=t; c*=t; }
30  };
31 
32  // multivariate homography
33  template<class real> struct homography_mv
34  {
36 
37  homography_mv() { H << homography<real>(); }
38  homography_mv(int n) {
39  for (int i=0;i<n;++i ) H << homography<real>();
40  }
41  homography_mv(const real& A, const real& B, const real& C, const real&D)
42  {
43  H << homography<real>(A,B,C,D);
44  }
45 
46  homography<real> operator[](int i) { return H[i]; }
47  homography<real> operator[](unsigned & i){ return H[i]; }
48 
49  void shift_hom (const real & t, const int & v) { H[v].shift_hom(t); }
50  void reciprocal_hom (const real & t, const int & v) { H[v].reciprocal_hom(t); }
51  void contract_hom (const real & t, const int & v) { H[v].contract_hom(t); }
52  void colapse () {for (unsigned j=0;j<H.size();j++) {
53  H[j].a=H[j].b;
54  H[j].c=H[j].d;
55  }
56  }
57  int size() {return H.size();}
58  };
59 
60 }
61 //====================================================================
62 #endif //realroot_homography_hpp
void reciprocal_hom(const real &t)
Definition: homography.hpp:26
int size()
Definition: homography.hpp:57
Sequence of terms with reference counter.
Definition: Seq.hpp:28
Definition: homography.hpp:33
homography(const real &A, const real &B, const real &C, const real &D)
Definition: homography.hpp:21
void shift_hom(const real &t, const int &v)
Definition: homography.hpp:49
MP swap(const MP &P, int var_i, int var_j)
Definition: sparse_monomials.hpp:988
real a
Definition: homography.hpp:17
homography_mv()
Definition: homography.hpp:37
homography(const homography &H)
Definition: homography.hpp:20
real c
Definition: homography.hpp:17
size_type size() const
Definition: Seq.hpp:166
void reciprocal_hom(const real &t, const int &v)
Definition: homography.hpp:50
void contract_hom(const real &t, const int &v)
Definition: homography.hpp:51
void contract_hom(const real &t)
Definition: homography.hpp:29
void colapse()
Definition: homography.hpp:52
void shift_hom(const real &t)
Definition: homography.hpp:23
Definition: homography.hpp:15
homography< real > operator[](int i)
Definition: homography.hpp:46
real b
Definition: homography.hpp:17
homography_mv(int n)
Definition: homography.hpp:38
double C
Definition: solver_mv_fatarcs.cpp:16
homography()
Definition: homography.hpp:19
homography< real > operator[](unsigned &i)
Definition: homography.hpp:47
Seq< homography< real > > H
Definition: homography.hpp:35
Definition: array.hpp:12
homography_mv(const real &A, const real &B, const real &C, const real &D)
Definition: homography.hpp:41
real d
Definition: homography.hpp:17
Home