IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Rotation2d.h
1 // Rotation2d.h:
3 // -------------
4 //
14 
15 #ifndef __IPSDKMATH_ROTATION2D_H__
16 #define __IPSDKMATH_ROTATION2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::math::transform::Rotation2d::g_registrator' : struct 'ipsdk::math::transform::Registrator<ipsdk::math::transform::Rotation2d>' needs to have dll-interface to be used by clients of class 'ipsdk::math::transform::Rotation2d'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
23 #include <IPSDKMath/Geometry/2d/Transform/BaseLinearGeometricTransform2d.h>
25 
26 namespace ipsdk {
27 namespace math {
28 namespace transform {
29 
32 
34 {
35 // predefined public type
36 public:
39 
40  (eTP_Theta)
41  );
42 
43  // declare geometric transformation 2d
45 
46 public:
49  Rotation2d()
50  {
51  setParams(0);
52  }
53  Rotation2d(const ipReal64 theta)
54  {
55  setParams(theta);
56  }
57  ~Rotation2d() {}
59 
60 // methods
61 public:
64  static void transform(const ipReal64 theta,
65  ipReal64& x, ipReal64& y)
66  {
67  transform(std::cos(theta), std::sin(theta), x, y);
68  }
69  static void transform(const ipReal64 cosTheta, const ipReal64 sinTheta,
70  ipReal64& x, ipReal64& y)
71  {
72  rotate2dInSitu(cosTheta, sinTheta, x, y);
73  }
75 
78  static Matrix3d getHomogenousMatrix(const ipReal64 theta)
79  {
80  return getHomogenousMatrix(std::cos(theta), std::sin(theta));
81  }
82  static Matrix3d getHomogenousMatrix(const ipReal64 cosTheta, const ipReal64 sinTheta)
83  {
84  Matrix3d transform;
85  angleToMatrix(cosTheta, sinTheta,
86  transform(0, 0), transform(0, 1),
87  transform(1, 0), transform(1, 1));
88  transform(0, 2) = 0;
89  transform(1, 2) = 0;
90  transform(2, 0) = 0; transform(2, 1) = 0; transform(2, 2) = 1;
91 
92  return transform;
93  }
95 
97  static Matrix3d getInvHomogenousMatrix(const ipReal64 theta)
98  {
99  return getHomogenousMatrix(-theta);
100  }
101 
103  static void getInvParams(ipReal64& theta)
104  {
105  theta = -theta;
106  }
107 
109  static Vector getIdentityParams();
110 
112  void setParams(const ipReal64 theta)
113  {
114  _theta = theta;
115  _cosTheta = std::cos(_theta);
116  _sinTheta = std::sin(_theta);
117  }
118 
122  void setParams(const Vector& params);
123 
125  void setIdentity();
126 
128  void apply(ipReal64& x, ipReal64& y) const;
129 
131  Matrix3d getHomogenousMatrix() const;
132 
134  Vector getParams() const;
135 
138  ipReal64 getTheta() const;
140 
142  Matrix3d getInvHomogenousMatrix() const;
143 
145  Vector getInvParams() const;
146 
147 // attributes
148 protected:
150  ipReal64 _theta;
151 
154  ipReal64 _cosTheta;
155  ipReal64 _sinTheta;
157 };
161 
162 inline ipReal64
163 Rotation2d::getTheta() const
164 {
165  return _theta;
166 }
167 
168 inline void
170 {
172 }
173 
176 
177 } // end of namespace transform
178 } // end of namespace math
179 } // end of namespace ipsdk
180 
181 #pragma warning (pop)
182 
183 #endif // __IPSDKMATH_ROTATION2D_H__
Transformation class allowing to manage 2d rotations.
Definition: Rotation2d.h:33
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void setIdentity()
set transformation parameters to identity
Definition: Rotation2d.h:172
IPSDK_FORCEINLINE void angleToMatrix(const T cosTheta, const T sinTheta, T &rxx, T &rxy, T &ryx, T &ryy)
Convertion from angle to rotation matrix.
Definition: Angles2d.h:80
static void transform(const ipReal64 theta, ipReal64 &x, ipReal64 &y)
application of transformation to a point
Definition: Rotation2d.h:67
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Utility functions used to handle angles 2d.
IPSDKGEOMETRY_API bool apply(const BaseGeometryTransform2d &transform, BaseGeometryEntity2d &entity)
function allowing to apply in situ a given transformation on an entity
eTransformParams
Definition: Rotation2d.h:40
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
static Vector getIdentityParams()
retrieve identity parameters for transformation
boost::numeric::ublas::bounded_matrix< ipReal64, 3, 3 > Matrix3d
3d matrix (3x3) type associated to library
Definition: LinearAlgebraTypes.h:54
ipReal64 getTheta() const
retrieve parameters associated to transformation
Definition: Rotation2d.h:166
ipReal64 _theta
angle of rotation in radians
Definition: Rotation2d.h:153
void setParams(const ipReal64 theta)
select parameters associated to transformation
Definition: Rotation2d.h:115
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
IPSDK_FORCEINLINE void rotate2dInSitu(const ipReal64 cosTheta, const ipReal64 sinTheta, T &x, T &y)
rotation of a point using a rotation angle (rotation around origin)
Definition: Angles2d.h:156
#define IPSDK_DECLARE_TRANSFORM2D(className)
macro allowing to declare a geometric transformation 2d
Definition: Transform2dHdrMacros.h:55