IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Scale2d.h
1 // Scale2d.h:
3 // ----------
4 //
14 
15 #ifndef __IPSDKMATH_SCALE2D_H__
16 #define __IPSDKMATH_SCALE2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Scale2d::g_registrator' : struct 'ipsdk::math::transform::Registrator<ipsdk::math::transform::Scale2d>' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Scale2d'
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_Scale)
40  );
41 
42  // declare geometric transformation 2d
44 
45 public:
48  Scale2d()
49  {
50  setParams(1);
51  }
52  Scale2d(const ipReal64 scale)
53  {
54  setParams(scale);
55  }
56  ~Scale2d() {}
58 
59 // methods
60 public:
63  static void transform(const ipReal64 scale,
64  ipReal64& x, ipReal64& y)
65  {
66  x *= scale;
67  y *= scale;
68  }
70 
73  static Matrix3d getHomogenousMatrix(const ipReal64 scale)
74  {
75  Matrix3d transform;
76  transform(0, 0) = scale; transform(0, 1) = 0; transform(0, 2) = 0;
77  transform(1, 0) = 0; transform(1, 1) = scale; transform(1, 2) = 0;
78  transform(2, 0) = 0; transform(2, 1) = 0; transform(2, 2) = 1;
79 
80  return transform;
81  }
83 
85  static Matrix3d getInvHomogenousMatrix(const ipReal64 scale)
86  {
87  ipReal64 invScale = 0;
88  if (scale != 0)
89  invScale = 1 / scale;
90  return getHomogenousMatrix(invScale);
91  }
92 
94  static void getInvParams(ipReal64& scale)
95  {
96  if (scale != 0)
97  scale = 1 / scale;
98  else
99  scale = 0;
100  }
101 
103  static Vector getIdentityParams();
104 
106  void setParams(const ipReal64 scale)
107  {
108  _scale = scale;
109  }
110 
114  void setParams(const Vector& params);
115 
117  void setIdentity();
118 
120  void apply(ipReal64& x, ipReal64& y) const;
121 
123  Matrix3d getHomogenousMatrix() const;
124 
126  Vector getParams() const;
127 
130  ipReal64 getScale() const;
132 
134  Matrix3d getInvHomogenousMatrix() const;
135 
137  Vector getInvParams() const;
138 
139 // attributes
140 protected:
142  ipReal64 _scale;
143 };
144 
147 
148 inline ipReal64
149 Scale2d::getScale() const
150 {
151  return _scale;
152 }
153 
154 inline void
156 {
158 }
159 
162 
163 } // end of namespace transform
164 } // end of namespace math
165 } // end of namespace ipsdk
166 
167 #pragma warning (pop)
168 
169 #endif // __IPSDKMATH_SCALE2D_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
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
void setParams(const ipReal64 scale)
select parameters associated to transformation
Definition: Scale2d.h:109
boost::numeric::ublas::vector< ipReal64 > Vector
vector type associated to library
Definition: LinearAlgebraTypes.h:36
void setIdentity()
set transformation parameters to identity
Definition: Scale2d.h:158
Definition: Scale2d.h:32
static Vector getIdentityParams()
retrieve identity parameters for transformation
#define IPSDKMATH_API
Import/Export macro for library IPSDKMath.
Definition: IPSDKMathExports.h:27
boost::numeric::ublas::bounded_matrix< ipReal64, 3, 3 > Matrix3d
3d matrix (3x3) type associated to library
Definition: LinearAlgebraTypes.h:54
eTransformParams
Definition: Scale2d.h:39
Transformation class allowing to manage 2d scale transformations.
ipReal64 _scale
transformation scale
Definition: Scale2d.h:145
ipReal64 getScale() const
retrieve parameters associated to transformation
Definition: Scale2d.h:152
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