IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Affine2d.h
1 // Affine2d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKMATH_AFFINE2D_H__
16 #define __IPSDKMATH_AFFINE2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Affine2d::g_registrator' : struct 'ipsdk::math::transform::Affine2d::Registrator' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Affine2d'
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_Axx)
40  (eTP_Axy)
41  (eTP_Ayx)
42  (eTP_Ayy)
43  (eTP_Tx)
44  (eTP_Ty)
45  );
46 
47  // declare geometric transformation 2d
49 
50 public:
53  Affine2d() :
54  _axx(1), _axy(0), _ayx(0), _ayy(1), _tx(0), _ty(0)
55  {
56  }
57  Affine2d(const ipReal64 axx, const ipReal64 axy,
58  const ipReal64 ayx, const ipReal64 ayy,
59  const ipReal64 tx, const ipReal64 ty) :
60  _axx(axx), _axy(axy), _ayx(ayx), _ayy(ayy), _tx(tx), _ty(ty)
61  {
62  }
63  ~Affine2d() {}
65 
66 // methods
67 public:
69  static void transform(const ipReal64 axx, const ipReal64 axy,
70  const ipReal64 ayx, const ipReal64 ayy,
71  const ipReal64 tx, const ipReal64 ty,
72  ipReal64& x, ipReal64& y)
73  {
74  const ipReal64 xTmp = axx*x + axy*y + tx;
75  const ipReal64 yTmp = ayx*x + ayy*y + ty;
76  x = xTmp;
77  y = yTmp;
78  }
79 
81  static Matrix3d getHomogenousMatrix(const ipReal64 axx, const ipReal64 axy,
82  const ipReal64 ayx, const ipReal64 ayy,
83  const ipReal64 tx, const ipReal64 ty)
84  {
85  Matrix3d transform;
86  transform(0, 0) = axx; transform(0, 1) = axy; transform(0, 2) = tx;
87  transform(1, 0) = ayx; transform(1, 1) = ayy; transform(1, 2) = ty;
88  transform(2, 0) = 0; transform(2, 1) = 0; transform(2, 2) = 1;
89 
90  return transform;
91  }
92 
96  static Matrix3d getInvHomogenousMatrix(const ipReal64 axx, const ipReal64 axy,
97  const ipReal64 ayx, const ipReal64 ayy,
98  const ipReal64 tx, const ipReal64 ty)
99  {
100  // invert input parameters
101  ipReal64 invAxx = axx;
102  ipReal64 invAxy = axy;
103  ipReal64 invAyx = ayx;
104  ipReal64 invAyy = ayy;
105  ipReal64 invTx = tx;
106  ipReal64 invTy = ty;
107  getInvParams(invAxx, invAxy, invAyx, invAyy, invTx, invTy);
108 
109  return getHomogenousMatrix(invAxx, invAxy, invAyx, invAyy, invTx, invTy);
110  }
111 
115  static void getInvParams(ipReal64& axx, ipReal64& axy,
116  ipReal64& ayx, ipReal64& ayy,
117  ipReal64& tx, ipReal64& ty);
118 
120  static Vector getIdentityParams();
121 
123  void setParams(const ipReal64 axx, const ipReal64 axy,
124  const ipReal64 ayx, const ipReal64 ayy,
125  const ipReal64 tx, const ipReal64 ty)
126  {
127  _axx = axx;
128  _axy = axy;
129  _ayx = ayx;
130  _ayy = ayy;
131  _tx = tx;
132  _ty = ty;
133  }
134 
138  void setParams(const Vector& params);
139 
141  void setIdentity();
142 
144  void apply(ipReal64& x, ipReal64& y) const;
145 
147  Matrix3d getHomogenousMatrix() const;
148 
150  Vector getParams() const;
151 
153  Matrix3d getInvHomogenousMatrix() const;
154 
156  Vector getInvParams() const;
157 
158 // attributes
159 protected:
162  ipReal64 _axx;
163  ipReal64 _axy;
164  ipReal64 _ayx;
165  ipReal64 _ayy;
167 
169  ipReal64 _tx;
172  ipReal64 _ty;
173 };
174 
178 inline void
180 {
182 }
183 
186 
187 } // end of namespace transform
188 } // end of namespace math
189 } // end of namespace ipsdk
190 
191 #pragma warning (pop)
192 
193 #endif // __IPSDKMATH_AFFINE2D_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
eTransformParams
Definition: Affine2d.h:39
void setParams(const ipReal64 axx, const ipReal64 axy, const ipReal64 ayx, const ipReal64 ayy, const ipReal64 tx, const ipReal64 ty)
select parameters associated to transformation
Definition: Affine2d.h:131
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
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
static Vector getIdentityParams()
retrieve identity parameters for transformation
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
Transformation class allowing to manage 2d affine transformations.
Definition: Affine2d.h:32
boost::numeric::ublas::bounded_matrix< ipReal64, 3, 3 > Matrix3d
3d matrix (3x3) type associated to library
Definition: LinearAlgebraTypes.h:54
void setIdentity()
set transformation parameters to identity
Definition: Affine2d.h:187
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