aimstil  5.0.5
AffineTransform.h
Go to the documentation of this file.
1 #ifndef TIL_AFFINE_H
2 #define TIL_AFFINE_H
3 
4 // include from TIL library
5 #include "til/til_common.h"
6 #include "til/labels.h"
7 #include "til/Matrix3.h"
8 #include "til/numeric_array.h"
9 #include "til/traits.h"
10 
11 // Namespace
12 namespace til
13 {
14  //namespace math {
15 
25 
26  // TODO: I don't see any reason to get stuck in 3D here
27 
28  template < typename T >
29  class Affine
30  {
31 
32  public: // constructors & destructor
33 
34  Affine() {};
35  Affine(const Matrix3<T> & m, const numeric_array<T,3> & transl)
36  : m_mat(m), m_transl(transl) {};
37 
38 
39  public: // set & get
40 
41  const Matrix3<T> & getMatrix() const { return m_mat; }
42  const numeric_array<T,3> & getTransl() const { return m_transl; }
43  Matrix3<T> & getMatrix() { return m_mat; }
44  numeric_array<T,3> & getTransl() { return m_transl; }
45 
46  void setMatrix(const Matrix3<T> &m) { m_mat = m; }
47  void setTransl(const numeric_array<T,3> &transl) { m_transl = transl; }
48 
49 
50  public: // functions
51 
52  void reset()
53  {
54  m_mat.reset();
55  fill(m_transl, 0);
56  }
57 
58 
59  private: // data
60 
61  Matrix3<T> m_mat;
62  numeric_array<T,3> m_transl;
63  };
64 
65 
66  namespace functor
67  {
68  template < typename T1, typename T2 >
69  struct Mul<Affine<T1>, numeric_array<T2,3> >
70  : public std::binary_function<const Affine<T1> &, const numeric_array<T2,3>, numeric_array<typename combine<T1, T2>::type, 3> >
71  {
72  typedef std::binary_function<const Affine<T1> &, const numeric_array<T2,3>, numeric_array<typename combine<T1, T2>::type, 3> > Base;
73  typedef typename Base::first_argument_type first_argument_type;
74  typedef typename Base::second_argument_type second_argument_type;
75  typedef typename Base::result_type result_type;
76 
77  Mul() : Base() {}
78 
79  result_type operator()(first_argument_type a, second_argument_type v) const
80  {
81  return a.getMatrix() * v + a.getTransl();
82  }
83  };
84  }
85 
86 
88  template <typename T1, typename T2>
89  INLINE
92  {
94  //return a.getMatrix() * v + a.getTransl();
95  }
96 
97  template <typename T1, typename T2>
98  inline T2 operator*(const Affine<T1> & a, const T2 & v)
99  {
100  return a.getMatrix() * v + a.getTransl();
101  //return a.getMatrix() * v + a.getTransl();
102  }
103 
104  /*
106  template <typename T1, typename T2>
107  INLINE
108  numeric_array<typename combine<T1, T2>::type, 4>
109  operator*(const Affine<T1> &a, const numeric_array<T2, 4> &v)
110  {
111  return a.getMatrix() * v + a.getTransl();
112  }
113  */
114 
115  //} // namespace math
116 } // namespace til
117 
118 // Package includes
120 
121 #endif
122 
void setMatrix(const Matrix3< T > &m)
std::binary_function< const Affine< T1 > &, const numeric_array< T2, 3 >, numeric_array< typename combine< T1, T2 >::type, 3 > > Base
A affine mathematical object.
Affine(const Matrix3< T > &m, const numeric_array< T, 3 > &transl)
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
numeric_array< T, 3 > & getTransl()
const Matrix3< T > & getMatrix() const
General macros, definitions and functions.
Defines empty classes that serves as labels.
const numeric_array< T, 3 > & getTransl() const
INLINE numeric_array< typename combine< T1, T2 >::type, 3 > operator*(const Affine< T1 > &a, const numeric_array< T2, 3 > &v)
Multiplication between a 3D affine transform and a 3D vector.
#define INLINE
Definition: til_common.h:26
A mathematical matrix.
Definition: Matrix3.h:90
void setTransl(const numeric_array< T, 3 > &transl)
Multiplication functor.
Definition: functors.h:293
result_type operator()(first_argument_type a, second_argument_type v) const
void fill(sparse_vector< T, BaselinePolicy > &v, typename boost::call_traits< T >::param_type value)
Specialized fill for sparse_vector.
Matrix3< T > & getMatrix()