IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Affine3d.h
1 // Affine3d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKMATH_AFFINE3D_H__
16 #define __IPSDKMATH_AFFINE3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Affine3d::g_registrator' : struct 'ipsdk::math::transform::Registrator<ipsdk::math::transform::Affine3d>' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Affine3d'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKMath/Geometry/3d/Transform/BaseLinearGeometricTransform3d.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_Axz)
42  (eTP_Ayx)
43  (eTP_Ayy)
44  (eTP_Ayz)
45  (eTP_Azx)
46  (eTP_Azy)
47  (eTP_Azz)
48  (eTP_Tx)
49  (eTP_Ty)
50  (eTP_Tz)
51  );
52 
53  // declare geometric transformation 3d
55 
56 public:
62  _axx(1), _axy(0), _axz(0), _ayx(0), _ayy(1), _ayz(0), _azx(0), _azy(0), _azz(1), _tx(0), _ty(0), _tz(0)
63  {
64  }
65  Affine3d(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz,
66  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz,
67  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz,
68  const ipReal64 tx, const ipReal64 ty, const ipReal64 tz) :
69  _axx(axx), _axy(axy), _axz(axz), _ayx(ayx), _ayy(ayy), _ayz(ayz), _azx(azx), _azy(azy), _azz(azz), _tx(tx), _ty(ty), _tz(tz)
70  {
71  }
72  ~Affine3d() {}
74 
75 // methods
76 public:
78  static void transform(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz,
79  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz,
80  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz,
81  const ipReal64 tx, const ipReal64 ty, const ipReal64 tz,
82  ipReal64& x, ipReal64& y, ipReal64& z)
83  {
84  const ipReal64 xTmp = axx*x + axy*y + axz*z + tx;
85  const ipReal64 yTmp = ayx*x + ayy*y + ayz*z + ty;
86  const ipReal64 zTmp = azx*x + azy*y + azz*z + tz;
87  x = xTmp;
88  y = yTmp;
89  z = zTmp;
90  }
91 
93  static Matrix4d getHomogenousMatrix(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz,
94  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz,
95  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz,
96  const ipReal64 tx, const ipReal64 ty, const ipReal64 tz)
97  {
98  Matrix4d transform;
99  transform(0, 0) = axx; transform(0, 1) = axy; transform(0, 2) = axz; transform(0, 3) = tx;
100  transform(1, 0) = ayx; transform(1, 1) = ayy; transform(1, 2) = ayz; transform(1, 3) = ty;
101  transform(2, 0) = azx; transform(2, 1) = azy; transform(2, 2) = azz; transform(2, 3) = tz;
102  transform(3, 0) = 0; transform(3, 1) = 0; transform(3, 2) = 0; transform(3, 3) = 1;
103 
104  return transform;
105  }
106 
111  static Matrix4d getInvHomogenousMatrix(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz,
112  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz,
113  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz,
114  const ipReal64 tx, const ipReal64 ty, const ipReal64 tz)
115  {
116  // invert input parameters
117  ipReal64 invAxx = axx;
118  ipReal64 invAxy = axy;
119  ipReal64 invAxz = axz;
120  ipReal64 invAyx = ayx;
121  ipReal64 invAyy = ayy;
122  ipReal64 invAyz = ayz;
123  ipReal64 invAzx = azx;
124  ipReal64 invAzy = azy;
125  ipReal64 invAzz = azz;
126  ipReal64 invTx = tx;
127  ipReal64 invTy = ty;
128  ipReal64 invTz = tz;
129  getInvParams(invAxx, invAxy, invAxz,
130  invAyx, invAyy, invAyz,
131  invAzx, invAzy, invAzz,
132  invTx, invTy, invTz);
133 
134  return getHomogenousMatrix(invAxx, invAxy, invAxz,
135  invAyx, invAyy, invAyz,
136  invAzx, invAzy, invAzz,
137  invTx, invTy, invTz);
138  }
139 
143  static void getInvParams(ipReal64& axx, ipReal64& axy, ipReal64& axz,
144  ipReal64& ayx, ipReal64& ayy, ipReal64& ayz,
145  ipReal64& azx, ipReal64& azy, ipReal64& azz,
146  ipReal64& tx, ipReal64& ty, ipReal64& tz);
147 
149  static Vector getIdentityParams();
150 
152  void setParams(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz,
153  const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz,
154  const ipReal64 azx, const ipReal64 azy, const ipReal64 azz,
155  const ipReal64 tx, const ipReal64 ty, const ipReal64 tz)
156  {
157  _axx = axx; _axy = axy; _axz = axz;
158  _ayx = ayx; _ayy = ayy; _ayz = ayz;
159  _azx = azx; _azy = azy; _azz = azz;
160  _tx = tx; _ty = ty; _tz = tz;
161  }
162 
166  void setParams(const Vector& params);
167 
169  void setIdentity();
170 
172  void apply(ipReal64& x, ipReal64& y, ipReal64& z) const;
173 
175  Matrix4d getHomogenousMatrix() const;
176 
178  Vector getParams() const;
179 
181  Matrix4d getInvHomogenousMatrix() const;
182 
184  Vector getInvParams() const;
185 
186 // attributes
187 protected:
190  ipReal64 _axx;
191  ipReal64 _axy;
192  ipReal64 _axz;
193  ipReal64 _ayx;
194  ipReal64 _ayy;
195  ipReal64 _ayz;
196  ipReal64 _azx;
197  ipReal64 _azy;
198  ipReal64 _azz;
200 
202  ipReal64 _tx;
203 
205  ipReal64 _ty;
208  ipReal64 _tz;
209 };
213 
214 inline void
216 {
218 }
223 } // end of namespace transform
224 } // end of namespace math
225 } // end of namespace ipsdk
226 
227 #pragma warning (pop)
228 
229 #endif // __IPSDKMATH_AFFINE3D_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
static Vector getIdentityParams()
retrieve identity parameters for transformation
Base class for linear geometric transformation 3d management.
Definition: BaseLinearGeometricTransform3d.h:27
void setIdentity()
set transformation parameters to identity
Definition: Affine3d.h:229
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
void setParams(const ipReal64 axx, const ipReal64 axy, const ipReal64 axz, const ipReal64 ayx, const ipReal64 ayy, const ipReal64 ayz, const ipReal64 azx, const ipReal64 azy, const ipReal64 azz, const ipReal64 tx, const ipReal64 ty, const ipReal64 tz)
select parameters associated to transformation
Definition: Affine3d.h:166
eTransformParams
Definition: Affine3d.h:39
IPSDKGEOMETRY_API bool apply(const BaseGeometryTransform2d &transform, BaseGeometryEntity2d &entity)
function allowing to apply in situ a given transformation on an entity
#define IPSDK_DECLARE_TRANSFORM3D(className)
macro allowing to declare a geometric transformation 3d
Definition: Transform3dHdrMacros.h:54
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
Transformation class allowing to manage 3d affine transformations.
Definition: Affine3d.h:32
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
boost::numeric::ublas::bounded_matrix< ipReal64, 4, 4 > Matrix4d
4d matrix (4x4) type associated to library
Definition: LinearAlgebraTypes.h:57
#define IPSDK_ENUM(enumTypeStr, enumSeq)
macro allowing to declare an enumerate for library
Definition: EnumMacros.h:26