[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN se2.h so2.h so3.h
From: |
Gerhard Reitmayr |
Subject: |
[Toon-members] TooN se2.h so2.h so3.h |
Date: |
Wed, 29 Apr 2009 16:05:50 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Gerhard Reitmayr <gerhard> 09/04/29 16:05:50
Modified files:
. : se2.h so2.h so3.h
Log message:
doc updates for SXX classes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/se2.h?cvsroot=toon&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/TooN/so2.h?cvsroot=toon&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/TooN/so3.h?cvsroot=toon&r1=1.34&r2=1.35
Patches:
Index: se2.h
===================================================================
RCS file: /cvsroot/toon/TooN/se2.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- se2.h 27 Apr 2009 13:36:32 -0000 1.6
+++ se2.h 29 Apr 2009 16:05:50 -0000 1.7
@@ -38,34 +38,67 @@
namespace TooN {
+/// Represent a two-dimensional Euclidean transformation (a rotation and a
translation).
+/// This can be represented by a \f$2\times 3\f$ matrix operating on a
homogeneous co-ordinate,
+/// so that a vector \f$\underline{x}\f$ is transformed to a new location
\f$\underline{x}'\f$
+/// by
+/// \f[\begin{aligned}\underline{x}' &= E\times\underline{x}\\
\begin{bmatrix}x'\\y'\end{bmatrix} &= \begin{pmatrix}r_{11} & r_{12} &
t_1\\r_{21} & r_{22} &
t_2\end{pmatrix}\begin{bmatrix}x\\y\\1\end{bmatrix}\end{aligned}\f]
+///
+/// This transformation is a member of the Special Euclidean Lie group SE2.
These can be parameterised with
+/// three numbers (in the space of the Lie Algebra). In this class, the first
two parameters are a
+/// translation vector while the third is the amount of rotation in the plane
as for SO2.
+/// @ingroup gTransforms
template <typename Precision = double>
class SE2 {
public:
+ /// Default constructor. Initialises the the rotation to zero (the
identity) and the translation to zero
SE2() : my_translation(Zeros) {}
template <class A> SE2(const SO2<Precision>& R, const
Vector<2,Precision,A>& T) : my_rotation(R), my_translation(T) {}
template <int S, class P, class A> SE2(const Vector<S, P, A> & v) {
*this = exp(v); }
+ /// Returns the rotation part of the transformation as a SO2
SO2<Precision> & get_rotation(){return my_rotation;}
+ /// @overload
const SO2<Precision> & get_rotation() const {return my_rotation;}
+ /// Returns the translation part of the transformation as a Vector
Vector<2, Precision> & get_translation() {return my_translation;}
+ /// @overload
const Vector<2, Precision> & get_translation() const {return
my_translation;}
+ /// Exponentiate a Vector in the Lie Algebra to generate a new SE2.
+ /// See the Detailed Description for details of this vector.
+ /// @param vect The Vector to exponentiate
template <int S, typename P, typename A>
static inline SE2 exp(const Vector<S,P, A>& vect);
+
+ /// Take the logarithm of the matrix, generating the corresponding
vector in the Lie Algebra.
+ /// See the Detailed Description for details of this vector.
static inline Vector<3, Precision> ln(const SE2& se2);
+ /// @overload
Vector<3, Precision> ln() const { return SE2::ln(*this); }
+ /// compute the inverse of the transformation
SE2 inverse() const {
const SO2<Precision> & rinv = my_rotation.inverse();
return SE2(rinv, -(rinv*my_translation));
};
+ /// Right-multiply by another SE2 (concatenate the two transformations)
+ /// @param rhs The multipier
inline SE2 operator *(const SE2& rhs) const { return
SE2(my_rotation*rhs.my_rotation, my_translation +
my_rotation*rhs.my_translation); }
+
+ /// Self right-multiply by another SE2 (concatenate the two
transformations)
+ /// @param rhs The multipier
inline SE2& operator *=(const SE2& rhs) {
*this = *this * rhs;
return *this;
}
+ /// returns the generators for the Lie group. These are a set of
matrices that
+ /// form a basis for the vector space of the Lie algebra.
+ /// @item 0 is translation in x
+ /// @item 1 is translation in y
+ /// @item 2 is rotation in the plane
static inline Matrix<3,3, Precision> generator(int i) {
Matrix<3,3,Precision> result(Zeros);
if(i < 2){
@@ -104,7 +137,8 @@
Vector<2, Precision> my_translation;
};
-// operator ostream& <<
+/// Write an SE2 to a stream
+/// @relates SE2
template <class Precision>
inline std::ostream& operator<<(std::ostream& os, const SE2<Precision> & rhs){
for(int i=0; i<2; i++)
@@ -112,7 +146,8 @@
return os;
}
-// operator istream& >>
+/// Read an SE2 from a stream
+/// @relates SE2
template <class Precision>
inline std::istream& operator>>(std::istream& is, SE2<Precision>& rhs){
for(int i=0; i<2; i++)
@@ -149,11 +184,15 @@
int size() const { return 3; }
};
+/// Right-multiply with a Vector<3>
+/// @relates SE2
template<int S, typename P, typename PV, typename A>
inline Vector<3, typename Internal::MultiplyType<P,PV>::type> operator*(const
SE2<P> & lhs, const Vector<S,PV,A>& rhs){
return Vector<3, typename
Internal::MultiplyType<P,PV>::type>(Operator<Internal::SE2VMult<S,P,PV,A>
>(lhs,rhs));
}
+/// Right-multiply with a Vector<2> (special case, extended to be a
homogeneous vector)
+/// @relates SE2
template <typename P, typename PV, typename A>
inline Vector<2, typename Internal::MultiplyType<P,PV>::type> operator*(const
SE2<P>& lhs, const Vector<2,PV,A>& rhs){
return lhs.get_translation() + lhs.get_rotation() * rhs;
@@ -186,6 +225,8 @@
int size() const { return 3; }
};
+/// Left-multiply with a Vector<3>
+/// @relates SE2
template<int S, typename P, typename PV, typename A>
inline Vector<3, typename Internal::MultiplyType<PV,P>::type> operator*(const
Vector<S,PV,A>& lhs, const SE2<P> & rhs){
return Vector<3, typename
Internal::MultiplyType<PV,P>::type>(Operator<Internal::VSE2Mult<S, P,PV,A>
>(lhs,rhs));
@@ -218,6 +259,8 @@
int num_rows() const { return 3; }
};
+/// Right-multiply with a Matrix<3>
+/// @relates SE2
template <int R, int Cols, typename PM, typename A, typename P>
inline Matrix<3,Cols, typename Internal::MultiplyType<P,PM>::type>
operator*(const SE2<P> & lhs, const Matrix<R,Cols,PM, A>& rhs){
return Matrix<3,Cols,typename
Internal::MultiplyType<P,PM>::type>(Operator<Internal::SE2MMult<R, Cols, PM, A,
P> >(lhs,rhs));
@@ -250,6 +293,8 @@
int num_rows() const { return lhs.num_rows(); }
};
+/// Left-multiply with a Matrix<3>
+/// @relates SE2
template <int Rows, int C, typename PM, typename A, typename P>
inline Matrix<Rows,3, typename Internal::MultiplyType<PM,P>::type>
operator*(const Matrix<Rows,C,PM, A>& lhs, const SE2<P> & rhs ){
return Matrix<Rows,3,typename
Internal::MultiplyType<PM,P>::type>(Operator<Internal::MSE2Mult<Rows, C, PM, A,
P> >(lhs,rhs));
@@ -321,6 +366,9 @@
return result;
}
+/// Multiply a SO2 with and SE2
+/// @relates SE2
+/// @relates SO2
template <typename Precision>
inline SE2<Precision> operator*(const SO2<Precision> & lhs, const
SE2<Precision>& rhs){
return SE2<Precision>( lhs*rhs.get_rotation(),
lhs*rhs.get_translation());
Index: so2.h
===================================================================
RCS file: /cvsroot/toon/TooN/so2.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- so2.h 14 Apr 2009 12:42:36 -0000 1.9
+++ so2.h 29 Apr 2009 16:05:50 -0000 1.10
@@ -42,18 +42,25 @@
template<typename Precision> inline std::istream & operator>>(std::istream &,
SO2<Precision> & );
template<typename Precision> inline std::istream & operator>>(std::istream &,
SE2<Precision> & );
+/// Class to represent a two-dimensional rotation matrix. Two-dimensional
rotation
+/// matrices are members of the Special Orthogonal Lie group SO2. This group
can be parameterised with
+/// one number (the rotation angle).
+/// @ingroup gTransforms
template<typename Precision = double>
class SO2 {
friend std::istream& operator>> <Precision>(std::istream&, SO2& );
friend std::istream& operator>> <Precision>(std::istream&,
SE2<Precision>& );
public:
+ /// Default constructor. Initialises the matrix to the identity (no
rotation)
SO2() : my_matrix(Identity) {}
SO2(const Matrix<2,2,Precision>& rhs) { *this = rhs; }
SO2(const Precision l) { *this = exp(l); }
+ /// Assigment operator from a general matrix. This also calls coerce()
+ /// to make sure that the matrix is a valid rotation matrix.
template <int R, int C, typename P, typename A>
inline SO2& operator=(const Matrix<R,C,P,A>& rhs){
my_matrix = rhs;
@@ -61,12 +68,14 @@
return *this;
}
+ /// Modifies the matrix to make sure it is a valid rotation matrix.
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]);
}
+ /// Exponentiate an angle in the Lie algebra to generate a new SO2.
inline static SO2 exp(const Precision & d){
SO2<Precision> result;
result.my_matrix[0][0] = result.my_matrix[1][1] = cos(d);
@@ -75,16 +84,22 @@
return result;
}
+ /// extracts the rotation angle from the SO2
Precision ln() const { return atan2(my_matrix[1][0], my_matrix[0][0]); }
+ /// Returns the inverse of this matrix (=the transpose, so this is a
fast operation)
SO2 inverse() const { return SO2(*this, Invert()); }
+ /// Self right-multiply by another rotation matrix
SO2& operator *=(const SO2& rhs){
my_matrix=my_matrix*rhs.my_matrix;
return *this;
}
+
+ /// Right-multiply by another rotation matrix
SO2 operator *(const SO2& rhs) const { return SO2(*this,rhs); }
+ /// Returns the SO2 as a Matrix<2>
const Matrix<2,2,Precision>& get_matrix() const {return my_matrix;}
/// returns generator matrix
@@ -103,32 +118,44 @@
Matrix<2,2,Precision> my_matrix;
};
+/// Write an SO2 to a stream
+/// @relates SO2
template <typename Precision>
inline std::ostream& operator<< (std::ostream& os, const SO2<Precision> & rhs){
return os << rhs.get_matrix();
}
+/// Read from SO2 to a stream
+/// @relates SO2
template <typename Precision>
inline std::istream& operator>>(std::istream& is, SO2<Precision>& rhs){
return is >> rhs.my_matrix;
rhs.coerce();
}
+/// Right-multiply by a Vector
+/// @relates SO2
template<int D, typename P1, typename PV, typename Accessor>
inline Vector<2, typename Internal::MultiplyType<P1, PV>::type>
operator*(const SO2<P1> & lhs, const Vector<D, PV, Accessor> & rhs){
return lhs.get_matrix() * rhs;
}
+/// Left-multiply by a Vector
+/// @relates SO2
template<int D, typename P1, typename PV, typename Accessor>
inline Vector<2, typename Internal::MultiplyType<PV,P1>::type> operator*(const
Vector<D, PV, Accessor>& lhs, const SO2<P1> & rhs){
return lhs * rhs.get_matrix();
}
+/// Right-multiply by a Matrix
+/// @relates SO2
template <int R, int C, typename P1, typename P2, typename Accessor>
inline Matrix<2,C,typename Internal::MultiplyType<P1,P2>::type>
operator*(const SO2<P1> & lhs, const Matrix<R,C,P2,Accessor>& rhs){
return lhs.get_matrix() * rhs;
}
+/// Left-multiply by a Matrix
+/// @relates SO2
template <int R, int C, typename P1, typename P2, typename Accessor>
inline Matrix<R,2,typename Internal::MultiplyType<P1,P2>::type>
operator*(const Matrix<R,C,P1,Accessor>& lhs, const SO2<P2>& rhs){
return lhs * rhs.get_matrix();
Index: so3.h
===================================================================
RCS file: /cvsroot/toon/TooN/so3.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- so3.h 27 Apr 2009 13:36:33 -0000 1.34
+++ so3.h 29 Apr 2009 16:05:50 -0000 1.35
@@ -280,14 +280,14 @@
return lhs * rhs.get_matrix();
}
-/// Multiply two SO3 matrices
+/// Right-multiply by a matrix
/// @relates SO3
template<int R, int C, typename P, typename PM, typename A> inline
Matrix<3, C, typename Internal::MultiplyType<P, PM>::type> operator*(const
SO3<P>& lhs, const Matrix<R, C, PM, A>& rhs){
return lhs.get_matrix() * rhs;
}
-/// Multiply two SO3 matrices
+/// Left-multiply by a matrix
/// @relates SO3
template<int R, int C, typename P, typename PM, typename A> inline
Matrix<R, 3, typename Internal::MultiplyType<PM, P>::type> operator*(const
Matrix<R, C, PM, A>& lhs, const SO3<P>& rhs){
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN se2.h so2.h so3.h,
Gerhard Reitmayr <=