IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Square2d.h
1 // Square2d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_SQUARE2D_H__
16 #define __IPSDKGEOMETRY_SQUARE2D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Square2d<T>::_centerPt' : struct 'ipsdk::geom::Point2dData<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Square2d<T>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
24 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
25 #include <IPSDKGeometry/Entity/2d/Point/Point2d.h>
27 
28 namespace ipsdk {
29 namespace geom {
30 
33 
34 template <typename T>
36 {
37  // declare 2d geometry entity
39 
40 // predefined public types
41 public:
43  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Cartesian;
44 
46  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_Circle;
47 
48 public:
51  Square2d();
52  Square2d(const Point2dData<T>& centerPt, const T halfLength, const ipReal64 orientation);
53  Square2d(const Point2d<T>& centerPt, const T halfLength, const ipReal64 orientation);
54  Square2d(const T xCenter, const T yCenter, const T halfLength, const ipReal64 orientation);
55  ~Square2d();
57 
58 // methods
59 public:
61  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
62 
64  inline eEntity2dType getEntity2dType() const;
65 
68  inline void setCenter(const Point2dData<T>& centerPt);
69  inline void setCenter(const Point2d<T>& centerPt);
70  inline void setCenter(const T xMin, const T yMin);
71  inline void setHalfLength(const T halfLength);
72  inline void setOrientation(const ipReal64 orientation);
73  inline ipReal64 getOrientation() const;
74  inline T centerX() const;
75  inline T centerY() const;
76  inline const Point2dData<T>& center() const;
77  inline T getHalfLength() const;
78  inline T getLength() const;
80 
85  inline Point2dData<T> topLeftCorner() const;
86  inline Point2dData<T> topRightCorner() const;
87  inline Point2dData<T> bottomLeftCorner() const;
88  inline Point2dData<T> bottomRightCorner() const;
90 
91 // attributes
92 protected:
95 
98 
101 
102 };
103 
106 
107 template <typename T>
110 {
111  return g_coordinateSystem2dType;
112 }
113 
114 template <typename T>
115 inline eEntity2dType
117 {
118  return g_entity2dType;
119 }
120 
121 template <typename T>
122 inline void
124 {
125  _centerPt = centerPt;
126 }
127 
128 template <typename T>
129 inline void
131 {
132  _centerPt = centerPt.getCoords();
133 }
134 
135 template <typename T>
136 inline void
137 Square2d<T>::setCenter(const T xMin, const T yMin)
138 {
139  _centerPt.setCoords(xMin, yMin);
140 }
141 
142 template <typename T>
143 inline void
144 Square2d<T>::setHalfLength(const T halfLength)
145 {
146  _halfLength = halfLength;
147 }
148 
149 template <typename T>
150 inline T
152 {
153  return _centerPt._x;
154 }
155 
156 template <typename T>
157 inline T
159 {
160  return _centerPt._y;
161 }
162 
163 template <typename T>
164 inline void
166 {
167  _orientation = orientation;
168 }
169 
170 template <typename T>
171 inline const Point2dData<T>&
173 {
174  return _centerPt;
175 }
176 
177 template <typename T>
178 inline T
180 {
181  return _halfLength;
182 }
183 
184 template <typename T>
185 inline T
187 {
188  return 2*_halfLength;
189 }
190 
191 template <typename T>
192 inline ipReal64
194 {
195  return _orientation;
196 }
197 
198 template <typename T>
199 inline Point2dData<T>
201 {
202  const ipReal64 modulus = std::sqrt(2*(_halfLength*_halfLength));
203  return Point2dData<T>(static_cast<T>(modulus*std::cos(_orientation+5.*M_PI/4.)) + _centerPt._x,
204  static_cast<T>(modulus*std::sin(_orientation+5.*M_PI/4.)) + _centerPt._y);
205 }
206 
207 template <typename T>
208 inline Point2dData<T>
210 {
211  const ipReal64 modulus = std::sqrt(2*(_halfLength*_halfLength));
212  return Point2dData<T>(static_cast<T>(modulus*std::cos(_orientation-M_PI/4.)) + _centerPt._x,
213  static_cast<T>(modulus*std::sin(_orientation-M_PI/4.)) + _centerPt._y);
214 }
215 
216 template <typename T>
217 inline Point2dData<T>
219 {
220  const ipReal64 modulus = std::sqrt(2*(_halfLength*_halfLength));
221  return Point2dData<T>(static_cast<T>(modulus*std::cos(_orientation+3.*M_PI/4.)) + _centerPt._x,
222  static_cast<T>(modulus*std::sin(_orientation+3.*M_PI/4.)) + _centerPt._y);
223 }
224 
225 template <typename T>
226 inline Point2dData<T>
228 {
229  const ipReal64 modulus = std::sqrt(2*(_halfLength*_halfLength));
230  return Point2dData<T>(static_cast<T>(modulus*std::cos(_orientation+M_PI/4.)) + _centerPt._x,
231  static_cast<T>(modulus*std::sin(_orientation+M_PI/4.)) + _centerPt._y);
232 }
233 
236 
237 } // end of namespace geom
238 } // end of namespace ipsdk
239 
240 #pragma warning (pop)
241 
242 #endif // __IPSDKGEOMETRY_SQUARE2D_H__
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: Square2d.h:109
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Point class associated to cartesian 2d coordinates.
Definition: GeometryEntity2dTypes.h:28
Point2dData< T > topLeftCorner() const
compute square corners coordinates For instance, the topLeftCorner() method calculates the square cor...
Definition: Square2d.h:200
IPSDK_FORCEINLINE PackT sqrt(const PackT &in)
returns the square root of a pack
Definition: sqrt.h:40
Circle.
Definition: GeometryEntity2dTypes.h:54
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
void setCenter(const Point2dData< T > &centerPt)
access to point coordinates
Definition: Square2d.h:123
void setHalfLength(const T halfLength)
access to point coordinates
Definition: Square2d.h:144
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
ipReal64 getOrientation() const
access to point coordinates
Definition: Square2d.h:193
T getHalfLength() const
access to point coordinates
Definition: Square2d.h:179
Definition of import/export macro for library.
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
void setOrientation(const ipReal64 orientation)
access to point coordinates
Definition: Square2d.h:165
ipReal64 _orientation
orientation (in radian) of the square
Definition: Square2d.h:100
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: Square2d.h:116
T centerX() const
access to point coordinates
Definition: Square2d.h:151
T getLength() const
access to point coordinates
Definition: Square2d.h:186
Point2dData< T > bottomRightCorner() const
compute square corners coordinates For instance, the topLeftCorner() method calculates the square cor...
Definition: Square2d.h:227
const Point2dData< T > & center() const
access to point coordinates
Definition: Square2d.h:172
const Point2dData< T > & getCoords() const
access to point coordinates
Definition: Point2d.h:139
T _halfLength
half length of the square sides
Definition: Square2d.h:97
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
Point2dData< T > _centerPt
coordinates associated to the center of the square
Definition: Square2d.h:94
2d square class associated to cartesian 2d coordinates
Definition: Square2d.h:35
Point2dData< T > bottomLeftCorner() const
compute square corners coordinates For instance, the topLeftCorner() method calculates the square cor...
Definition: Square2d.h:218
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
Point2dData< T > topRightCorner() const
compute square corners coordinates For instance, the topLeftCorner() method calculates the square cor...
Definition: Square2d.h:209
T centerY() const
access to point coordinates
Definition: Square2d.h:158
Cartesian coordinate system.
Definition: GeometryEntity2dTypes.h:78