31 #ifndef TOON_INCLUDE_SIM2_H 32 #define TOON_INCLUDE_SIM2_H 35 #include <TooN/sim3.h> 49 template <
typename Precision = DefaultPrecision>
69 const Precision &
get_scale()
const {
return my_scale;}
74 template <
int S,
typename P,
typename A>
86 const Precision inv_scale = 1/
get_scale();
131 template<
typename Accessor>
135 result.template slice<0,2>() =
get_rotation() * vect.template slice<0,2>();
141 template <
typename Accessor>
144 for(
int i=0; i<4; ++i)
145 result.T()[i] =
adjoint(M.T()[i]);
146 for(
int i=0; i<4; ++i)
147 result[i] =
adjoint(result[i]);
158 template <
class Precision>
159 inline std::ostream& operator<<(std::ostream& os, const SIM2<Precision> & rhs){
160 std::streamsize fw = os.width();
161 for(
int i=0; i<2; i++){
163 os << rhs.get_rotation().get_matrix()[i] * rhs.get_scale();
165 os << rhs.get_translation()[i] <<
'\n';
172 template <
class Precision>
174 for(
int i=0; i<2; i++)
188 template<
int S,
typename P,
typename PV,
typename A>
192 template<
int S,
typename P,
typename PV,
typename A>
199 template <
int S0,
typename P0,
typename A0>
202 res.template slice<0,2>()=lhs.get_rotation()*(lhs.get_scale()*rhs.template slice<0,2>());
203 res.template slice<0,2>()+=lhs.get_translation() * rhs[2];
206 int size()
const {
return 3; }
211 template<
int S,
typename P,
typename PV,
typename A>
218 template <
typename P,
typename PV,
typename A>
229 template<
int S,
typename P,
typename PV,
typename A>
233 template<
int S,
typename P,
typename PV,
typename A>
240 template <
int S0,
typename P0,
typename A0>
247 int size()
const {
return 3; }
252 template<
int S,
typename P,
typename PV,
typename A>
263 template <
int R,
int C,
typename PM,
typename A,
typename P>
267 template<
int R,
int Cols,
typename PM,
typename A,
typename P>
268 struct Operator<Internal::SIM2MMult<R, Cols, PM, A, P> > {
274 template <
int R0,
int C0,
typename P0,
typename A0>
277 for(
int i=0; i<rhs.num_cols(); ++i)
278 res.T()[i] = lhs * rhs.T()[i];
280 int num_cols()
const {
return rhs.num_cols(); }
281 int num_rows()
const {
return 3; }
286 template <
int R,
int Cols,
typename PM,
typename A,
typename P>
297 template <
int Rows,
int C,
typename PM,
typename A,
typename P>
301 template<
int Rows,
int C,
typename PM,
typename A,
typename P>
302 struct Operator<Internal::MSIM2Mult<Rows, C, PM, A, P> > {
308 template <
int R0,
int C0,
typename P0,
typename A0>
311 for(
int i=0; i<lhs.num_rows(); ++i)
312 res[i] = lhs[i] * rhs;
314 int num_cols()
const {
return 3; }
315 int num_rows()
const {
return lhs.num_rows(); }
320 template <
int Rows,
int C,
typename PM,
typename A,
typename P>
325 template <
typename Precision>
326 template <
int S,
typename PV,
typename Accessor>
330 static const Precision one_6th = 1.0/6.0;
331 static const Precision one_20th = 1.0/20.0;
338 const Precision theta = mu[2];
347 result.
get_translation() = coeff[2] * mu.template slice<0,2>() + TooN::operator*(coeff[1], cross);
352 template <
typename Precision>
366 const Vector<3, Precision> coeff = Internal::compute_rodrigues_coefficients_sim3(result[3], theta);
375 template <
typename Precision>
Matrix< R, C, P > exp(const Matrix< R, C, P, B > &m)
computes the matrix exponential of a matrix m by scaling m by 1/(powers of 2), using Taylor series an...
Definition: helpers.h:330
SO2< Precision > & get_rotation()
Returns the rotation part of the transformation as a SO2.
Definition: sim2.h:58
Vector< 4, Precision > adjoint(const Vector< 4, Precision, Accessor > &vect) const
transfers a vector in the Lie algebra, from one coord frame to another so that exp(adjoint(vect)) = (...
Definition: sim2.h:132
SIM2 inverse() const
compute the inverse of the transformation
Definition: sim2.h:84
Vector< 3, typename Internal::MultiplyType< PV, P >::type > operator*(const Vector< S, PV, A > &lhs, const SIM2< P > &rhs)
Left-multiply with a Vector<3>
Definition: sim2.h:253
Matrix< R, C, P > log(const Matrix< R, C, P, B > &m)
computes the matrix logarithm of a matrix m using the inverse scaling and squaring method...
Definition: helpers.h:373
Precision norm(const Vector< Size, Precision, Base > &v)
Compute the norm of v.
Definition: helpers.h:97
Pretty generic SFINAE introspection generator.
Definition: vec_test.cc:21
A vector.
Definition: vector.hh:126
Vector< 3, typename Internal::MultiplyType< P, PV >::type > operator*(const SIM2< P > &lhs, const Vector< S, PV, A > &rhs)
Right-multiply with a Vector<3>
Definition: sim2.h:212
SIM2()
Default constructor. Initialises the the rotation to zero (the identity), the scale factor to one and...
Definition: sim2.h:53
std::istream & operator>>(std::istream &is, SIM2< Precision > &rhs)
Read an SIM2 from a stream.
Definition: sim2.h:173
Class to represent a two-dimensional rotation matrix.
Definition: so2.h:37
Vector< 2, Precision > & get_translation()
Returns the translation part of the transformation as a Vector.
Definition: sim2.h:62
static SO2 exp(const Precision &d)
Exponentiate an angle in the Lie algebra to generate a new SO2.
Definition: so2.h:89
Precision & get_scale()
Returns the scale factor of the transformation.
Definition: sim2.h:67
Definition: operators.hh:119
SIM2 & operator*=(const SIM2 &rhs)
Self right-multiply by another SIM2 (concatenate the two transformations)
Definition: sim2.h:99
const SO2< Precision > & get_rotation() const
Definition: sim2.h:60
Represent a two-dimensional Similarity transformation (a rotation, a uniform scale and a translation)...
Definition: sim2.h:50
static Matrix< 3, 3, Precision > generator(int i)
returns the generators for the Lie group.
Definition: sim2.h:110
SIM2< typename Internal::MultiplyType< Precision, P >::type > operator*(const SIM2< P > &rhs) const
Right-multiply by another SIM2 (concatenate the two transformations)
Definition: sim2.h:93
const Precision & get_scale() const
Definition: sim2.h:69
Definition: size_mismatch.hh:103
static SIM2 exp(const Vector< S, P, A > &vect)
Exponentiate a Vector in the Lie Algebra to generate a new SIM2.
Vector< 2, Precision > & get_translation()
Returns the translation part of the transformation as a Vector.
Definition: se2.h:62
const Vector< 2, Precision > & get_translation() const
Definition: sim2.h:64
Represent a two-dimensional Euclidean transformation (a rotation and a translation).
Definition: se2.h:50
Vector< N, Precision > gaussian_elimination(Matrix< N, N, Precision > A, Vector< N, Precision > b)
Return the solution for , given and .
Definition: gaussian_elimination.h:43
Vector< 4, Precision > ln() const
Definition: sim2.h:81
SO2< Precision > & get_rotation()
Returns the rotation part of the transformation as a SO2.
Definition: se2.h:58
Matrix< 3, Cols, typename Internal::MultiplyType< P, PM >::type > operator*(const SIM2< P > &lhs, const Matrix< R, Cols, PM, A > &rhs)
Right-multiply with a Matrix<3>
Definition: sim2.h:287
Vector< 2, typename Internal::MultiplyType< P, PV >::type > operator*(const SIM2< P > &lhs, const Vector< 2, PV, A > &rhs)
Right-multiply with a Vector<2> (special case, extended to be a homogeneous vector) ...
Definition: sim2.h:219
Matrix< Rows, 3, typename Internal::MultiplyType< PM, P >::type > operator*(const Matrix< Rows, C, PM, A > &lhs, const SIM2< P > &rhs)
Left-multiply with a Matrix<3>
Definition: sim2.h:321