29 #ifndef TOON_INCLUDE_SO2_H 30 #define TOON_INCLUDE_SO2_H 32 #include <TooN/TooN.h> 33 #include <TooN/helpers.h> 37 template <
typename Precision>
class SO2;
38 template <
typename Precision>
class SE2;
39 template <
typename Precision>
class SIM2;
41 template<
typename Precision>
inline std::istream & operator>>(std::istream &,
SO2<Precision> & );
42 template<
typename Precision>
inline std::istream & operator>>(std::istream &,
SE2<Precision> & );
43 template<
typename Precision>
inline std::istream & operator>>(std::istream &,
SIM2<Precision> & );
49 template<
typename Precision = DefaultPrecision>
51 friend std::istream&
operator>> <Precision>(std::istream&,
SO2& );
52 friend std::istream&
operator>> <Precision>(std::istream&,
SE2<Precision>& );
53 friend std::istream&
operator>> <Precision>(std::istream&,
SIM2<Precision>& );
61 SO2() : my_matrix(Identity) {}
70 explicit SO2(
const Precision l) { *
this =
exp(l); }
74 template <
int R,
int C,
typename P,
typename A>
83 my_matrix[0] =
unit(my_matrix[0]);
84 my_matrix[1] -= my_matrix[0] * (my_matrix[0]*my_matrix[1]);
85 my_matrix[1] =
unit(my_matrix[1]);
89 inline static SO2 exp(
const Precision & d){
91 result.my_matrix[0][0] = result.my_matrix[1][1] = cos(d);
92 result.my_matrix[1][0] = sin(d);
93 result.my_matrix[0][1] = -result.my_matrix[1][0];
98 Precision
ln()
const {
return atan2(my_matrix[1][0], my_matrix[0][0]); }
104 template <
typename P>
111 template <
typename P>
122 result[0] = makeVector(0,-1);
123 result[1] = makeVector(1,0);
129 inline SO2(
const SO2& so2,
const Invert&) : my_matrix(so2.my_matrix.T()) {}
130 template <
typename PA,
typename PB>
138 template <
typename Precision>
139 inline std::ostream& operator<< (std::ostream& os, const SO2<Precision> & rhs){
140 return os << rhs.get_matrix();
145 template <
typename Precision>
154 template<
int D,
typename P1,
typename PV,
typename Accessor>
161 template<
int D,
typename P1,
typename PV,
typename Accessor>
168 template <
int R,
int C,
typename P1,
typename P2,
typename Accessor>
175 template <
int R,
int C,
typename P1,
typename P2,
typename Accessor>
std::istream & operator>>(std::istream &is, SO2< Precision > &rhs)
Read from SO2 to a stream.
Definition: so2.h:146
const Matrix< 2, 2, Precision > & get_matrix() const
Returns the SO2 as a Matrix<2>
Definition: so2.h:117
Vector< 2, typename Internal::MultiplyType< PV, P1 >::type > operator*(const Vector< D, PV, Accessor > &lhs, const SO2< P1 > &rhs)
Left-multiply by a Vector.
Definition: so2.h:162
Matrix< 2, C, typename Internal::MultiplyType< P1, P2 >::type > operator*(const SO2< P1 > &lhs, const Matrix< R, C, P2, Accessor > &rhs)
Right-multiply by a Matrix.
Definition: so2.h:169
Pretty generic SFINAE introspection generator.
Definition: vec_test.cc:21
A vector.
Definition: vector.hh:126
SO2(const Operator< Internal::Identity< Internal::One > > &)
Default constructor. Initialises the matrix to the identity (no rotation)
Definition: so2.h:57
Class to represent a two-dimensional rotation matrix.
Definition: so2.h:37
SO2< typename Internal::MultiplyType< Precision, P >::type > operator*(const SO2< P > &rhs) const
Right-multiply by another rotation matrix.
Definition: so2.h:112
static SO2 exp(const Precision &d)
Exponentiate an angle in the Lie algebra to generate a new SO2.
Definition: so2.h:89
void coerce()
Modifies the matrix to make sure it is a valid rotation matrix.
Definition: so2.h:82
SO2 & operator=(const Matrix< R, C, P, A > &rhs)
Assigment operator from a general matrix.
Definition: so2.h:75
Matrix< R, 2, typename Internal::MultiplyType< P1, P2 >::type > operator*(const Matrix< R, C, P1, Accessor > &lhs, const SO2< P2 > &rhs)
Left-multiply by a Matrix.
Definition: so2.h:176
Vector< 2, typename Internal::MultiplyType< P1, PV >::type > operator*(const SO2< P1 > &lhs, const Vector< D, PV, Accessor > &rhs)
Right-multiply by a Vector.
Definition: so2.h:155
Definition: operators.hh:119
SO2 inverse() const
Returns the inverse of this matrix (=the transpose, so this is a fast operation)
Definition: so2.h:101
static Matrix< 2, 2, Precision > generator()
returns generator matrix
Definition: so2.h:120
SO2 & operator*=(const SO2< P > &rhs)
Self right-multiply by another rotation matrix.
Definition: so2.h:105
Represent a two-dimensional Similarity transformation (a rotation, a uniform scale and a translation)...
Definition: sim2.h:50
SO2(const Matrix< 2, 2, Precision > &rhs)
Construct from a rotation matrix.
Definition: so2.h:64
Represent a two-dimensional Euclidean transformation (a rotation and a translation).
Definition: se2.h:50
SO2(const Precision l)
Construct from an angle.
Definition: so2.h:70
Precision ln() const
extracts the rotation angle from the SO2
Definition: so2.h:98
Vector< Size, Precision > unit(const Vector< Size, Precision, Base > &v)
Compute a the unit vector .
Definition: helpers.h:153