IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Translation2d.h
1 // Translation2d.h:
3 // ----------------
4 //
14 
15 #ifndef __IPSDKMATH_TRANSLATION2D_H__
16 #define __IPSDKMATH_TRANSLATION2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Translation2d::g_registrator' : struct 'ipsdk::math::transform::Registrator<ipsdk::math::transform::Translation2d>' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Translation2d'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKMath/Geometry/2d/Transform/BaseLinearGeometricTransform2d.h>
24 
25 namespace ipsdk {
26 namespace math {
27 namespace transform {
28 
31 
33 {
34 // predefined public type
35 public:
38 
39  (eTP_Tx)
40  (eTP_Ty)
41  );
42 
43  // declare geometric transformation 2d
45 
46 public:
49  Translation2d() :
50  _tx(0), _ty(0)
51  {
52  }
53  Translation2d(const ipReal64 tx, const ipReal64 ty) :
54  _tx(tx), _ty(ty)
55  {
56  }
57  ~Translation2d() {}
59 
60 // methods
61 public:
63  static void transform(const ipReal64 tx, const ipReal64 ty,
64  ipReal64& x, ipReal64& y)
65  {
66  x += tx;
67  y += ty;
68  }
69 
71  static Matrix3d getHomogenousMatrix(const ipReal64 tx, const ipReal64 ty)
72  {
73  Matrix3d transform;
74  transform(0, 0) = 1; transform(0, 1) = 0; transform(0, 2) = tx;
75  transform(1, 0) = 0; transform(1, 1) = 1; transform(1, 2) = ty;
76  transform(2, 0) = 0; transform(2, 1) = 0; transform(2, 2) = 1;
77 
78  return transform;
79  }
80 
82  static Matrix3d getInvHomogenousMatrix(const ipReal64 tx, const ipReal64 ty)
83  {
84  Matrix3d invTransform;
85  invTransform(0, 0) = 1; invTransform(0, 1) = 0; invTransform(0, 2) = -tx;
86  invTransform(1, 0) = 0; invTransform(1, 1) = 1; invTransform(1, 2) = -ty;
87  invTransform(2, 0) = 0; invTransform(2, 1) = 0; invTransform(2, 2) = 1;
88 
89  return invTransform;
90  }
91 
93  static void getInvParams(ipReal64& tx, ipReal64& ty)
94  {
95  tx = -tx;
96  ty = -ty;
97  }
98 
100  static Vector getIdentityParams();
101 
103  void setParams(const ipReal64 tx, const ipReal64 ty)
104  {
105  _tx = tx;
106  _ty = ty;
107  }
108 
112  void setParams(const Vector& params);
113 
115  void setIdentity();
116 
118  void apply(ipReal64& x, ipReal64& y) const;
119 
121  Matrix3d getHomogenousMatrix() const;
122 
124  Vector getParams() const;
125 
128  ipReal64 getTx() const;
129  ipReal64 getTy() const;
131 
133  Matrix3d getInvHomogenousMatrix() const;
134 
136  Vector getInvParams() const;
137 
138 // attributes
139 protected:
141  ipReal64 _tx;
142 
144  ipReal64 _ty;
145 };
146 
149 
150 inline ipReal64
151 Translation2d::getTx() const
152 {
153  return _tx;
154 }
156 inline ipReal64
157 Translation2d::getTy() const
158 {
159  return _ty;
160 }
162 inline void
164 {
166 }
170 
171 } // end of namespace transform
172 } // end of namespace math
173 } // end of namespace ipsdk
174 
175 #pragma warning (pop)
176 
177 #endif // __IPSDKMATH_TRANSLATION_H__
eTransformParams
Definition: Translation2d.h:39
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Transformation class allowing to manage 2d translations.
Definition: Translation2d.h:32
ipReal64 _tx
translation coordinate along x axis
Definition: Translation2d.h:145
static Vector getIdentityParams()
retrieve identity parameters for transformation
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
IPSDKGEOMETRY_API bool apply(const BaseGeometryTransform2d &transform, BaseGeometryEntity2d &entity)
function allowing to apply in situ a given transformation on an entity
ipReal64 _ty
translation coordinate along y axis
Definition: Translation2d.h:148
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
ipReal64 getTx() const
retrieve parameters associated to transformation
Definition: Translation2d.h:155
boost::numeric::ublas::bounded_matrix< ipReal64, 3, 3 > Matrix3d
3d matrix (3x3) type associated to library
Definition: LinearAlgebraTypes.h:54
ipReal64 getTy() const
retrieve parameters associated to transformation
Definition: Translation2d.h:161
void setParams(const ipReal64 tx, const ipReal64 ty)
select parameters associated to transformation
Definition: Translation2d.h:107
Base class for linear geometric transformation 2d management.
Definition: BaseLinearGeometricTransform2d.h:27
#define IPSDK_ENUM(enumTypeStr, enumSeq)
macro allowing to declare an enumerate for library
Definition: EnumMacros.h:26
#define IPSDK_DECLARE_TRANSFORM2D(className)
macro allowing to declare a geometric transformation 2d
Definition: Transform2dHdrMacros.h:55
void setIdentity()
set transformation parameters to identity
Definition: Translation2d.h:167