toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN se2.h se3.h so2.h so3.h test/SXX_test.cc


From: Gerhard Reitmayr
Subject: [Toon-members] TooN se2.h se3.h so2.h so3.h test/SXX_test.cc
Date: Tue, 07 Apr 2009 07:54:49 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Gerhard Reitmayr <gerhard>      09/04/07 07:54:49

Modified files:
        .              : se2.h se3.h so2.h so3.h 
        test           : SXX_test.cc 

Log message:
        fixed bug in SO3::coerce and removed from constructor (which uses the 
assignment operator anyway ;)
        clean-up of coerce in other classes

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/se2.h?cvsroot=toon&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/TooN/se3.h?cvsroot=toon&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/TooN/so2.h?cvsroot=toon&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/TooN/so3.h?cvsroot=toon&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/TooN/test/SXX_test.cc?cvsroot=toon&r1=1.6&r2=1.7

Patches:
Index: se2.h
===================================================================
RCS file: /cvsroot/toon/TooN/se2.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- se2.h       2 Apr 2009 13:36:03 -0000       1.2
+++ se2.h       7 Apr 2009 07:54:49 -0000       1.3
@@ -108,7 +108,7 @@
 inline std::istream& operator>>(std::istream& is, SE2<Precision>& rhs){
        for(int i=0; i<2; i++)
                is >> rhs.get_rotation().my_matrix[i].ref() >> 
rhs.get_translation()[i];
-       SO2<Precision>::coerce(rhs.get_rotation().my_matrix);
+       rhs.get_rotation().coerce();
        return is;
 }
 

Index: se3.h
===================================================================
RCS file: /cvsroot/toon/TooN/se3.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- se3.h       2 Apr 2009 13:36:04 -0000       1.18
+++ se3.h       7 Apr 2009 07:54:49 -0000       1.19
@@ -167,6 +167,7 @@
        for(int i=0; i<3; i++){
                is >> rhs.get_rotation().my_matrix[i].ref() >> 
rhs.get_translation()[i];
        }
+       rhs.get_rotation().coerce();
        return is;
 }
 

Index: so2.h
===================================================================
RCS file: /cvsroot/toon/TooN/so2.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- so2.h       2 Apr 2009 13:36:04 -0000       1.6
+++ so2.h       7 Apr 2009 07:54:49 -0000       1.7
@@ -48,17 +48,14 @@
        template <int R, int C, typename P, typename A> 
        inline SO2& operator=(const Matrix<R,C,P,A>& rhs){
                my_matrix = rhs;
-               coerce(my_matrix);
+               coerce();
                return *this;
        }
 
-       template <int R, int C, typename P, typename A> 
-       static inline void coerce(Matrix<R,C,P,A>& M){
-               SizeMismatch<2,R>::test(2, M.num_rows());
-               SizeMismatch<2,C>::test(2, M.num_cols());
-               M[0] = unit(M[0]);
-               M[1] -= M[0] * (M[0]*M[1]);
-               M[1] = unit(M[1]);
+       void coerce(){
+               my_matrix[0] = unit(my_matrix[0]);
+               my_matrix[1] -= my_matrix[0] * (my_matrix[0]*my_matrix[1]);
+               my_matrix[1] = unit(my_matrix[1]);
        }
 
        inline static SO2 exp(const Precision & d){
@@ -105,7 +102,7 @@
 template <typename Precision>
 inline std::istream& operator>>(std::istream& is, SO2<Precision>& rhs){
        return is >> rhs.my_matrix;
-       SO2<Precision>::coerce(rhs.my_matrix);
+       rhs.coerce();
 }
 
 template<int D, typename P1, typename PV, typename Accessor>

Index: so3.h
===================================================================
RCS file: /cvsroot/toon/TooN/so3.h,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- so3.h       7 Apr 2009 02:44:24 -0000       1.28
+++ so3.h       7 Apr 2009 07:54:49 -0000       1.29
@@ -46,7 +46,7 @@
        SO3(const Vector<S, P, A> & v) { *this = exp(v); }
        
        template <int R, int C, typename P, typename A>
-       SO3(const Matrix<R,C,P,A>& rhs) { *this = rhs; coerce();}
+       SO3(const Matrix<R,C,P,A>& rhs) { *this = rhs; }
        
        template <int R, int C, typename P, typename A>
        SO3& operator=(const Matrix<R,C,P,A> & rhs) {
@@ -56,6 +56,7 @@
        }
        
        void coerce() {
+               my_matrix[0] = unit(my_matrix[0]);
                my_matrix[1] -= my_matrix[0] * (my_matrix[0]*my_matrix[1]);
                my_matrix[1] = unit(my_matrix[1]);
                my_matrix[2] -= my_matrix[0] * (my_matrix[0]*my_matrix[2]);
@@ -105,6 +106,7 @@
 template <typename Precision>
 inline std::istream& operator>>(std::istream& is, SO3<Precision>& rhs){
        return is >> rhs.my_matrix;
+       rhs.coerce();
 }
 
 template <typename Precision, typename VA, typename MA>

Index: test/SXX_test.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/SXX_test.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- test/SXX_test.cc    2 Apr 2009 13:36:04 -0000       1.6
+++ test/SXX_test.cc    7 Apr 2009 07:54:49 -0000       1.7
@@ -158,6 +158,8 @@
     cout << "set from matrix (uses coerce)\n" << m << "\n";
     r = m;
     cout << r << endl;
+    TooN::SO3<> r5(m);
+    cout << r5 << endl;
 
     cout << "read from istream\n";
     istringstream is("0 -1 0 1 0 0 0 0 1");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]