realroot_doc 0.1.1
|
00001 /******************************************************************* 00002 * This file is part of the source code of realroot kernel. 00003 * Author(s): B. Mourrain, GALAAD, INRIA 00004 * A. Mantzaflaris, GALAAD, INRIA 00005 ********************************************************************/ 00006 #ifndef realroot_homography_hpp 00007 #define realroot_homography_hpp 00008 //==================================================================== 00009 00010 #include <realroot/Interval.hpp> 00011 00012 namespace mmx { 00013 00014 // (ax + b)/(cx + d) 00015 template<class real> struct homography 00016 { 00017 real a,b,c,d; 00018 00019 homography(): a(1),b(0),c(0),d(1) {} 00020 homography(const homography& H): a(H.a),b(H.b),c(H.c),d(H.d) {} 00021 homography(const real& A, const real& B, const real& C, const real&D): a(A),b(B),c(C),d(D) {} 00022 00023 void shift_hom (const real & t ) { b+=t*a; d+=t*c; } 00024 00025 // reciprocal_hom: t currently unused 00026 void reciprocal_hom(const real & t ) 00027 { std::swap(a,b); std::swap(c,d); } 00028 00029 void contract_hom (const real & t ) { a*=t; c*=t; } 00030 }; 00031 00032 // multivariate homography 00033 template<class real> struct homography_mv 00034 { 00035 Seq<homography<real> > H; 00036 00037 homography_mv() { H << homography<real>(); } 00038 homography_mv(int n) { 00039 for (int i=0;i<n;++i ) H << homography<real>(); 00040 } 00041 homography_mv(const real& A, const real& B, const real& C, const real&D) 00042 { 00043 H << homography<real>(A,B,C,D); 00044 } 00045 00046 homography<real> operator[](int i) { return H[i]; } 00047 homography<real> operator[](unsigned & i){ return H[i]; } 00048 00049 void shift_hom (const real & t, const int & v) { H[v].shift_hom(t); } 00050 void reciprocal_hom (const real & t, const int & v) { H[v].reciprocal_hom(t); } 00051 void contract_hom (const real & t, const int & v) { H[v].contract_hom(t); } 00052 void colapse () {for (unsigned j=0;j<H.size();j++) { 00053 H[j].a=H[j].b; 00054 H[j].c=H[j].d; 00055 } 00056 } 00057 int size() {return H.size();} 00058 }; 00059 00060 } 00061 //==================================================================== 00062 #endif //realroot_homography_hpp