IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Cube3d.h
1 // Cube3d.h:
3 // ---------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_CUBE3D_H__
16 #define __IPSDKGEOMETRY_CUBE3D_H__
17 
18 // suppression warnings
19 // warning C4251: 'ipsdk::geom::Cube3d<ipsdk::ipInt32>::_centerPt': struct 'ipsdk::geom::Point3dData<T>' needs to have dll-interface to be used by clients of class 'ipsdk::geom::Cube3d<ipsdk::ipInt32>'
20 #pragma warning (push)
21 #pragma warning (disable : 4251)
22 
24 #include <IPSDKGeometry/Entity/3d/BaseTypedGeometryEntity3d.h>
25 #include <IPSDKGeometry/Entity/3d/Point/Point3d.h>
27 
28 namespace ipsdk {
29 namespace geom {
30 
33 
34 template <typename T>
36 {
37  // declare 3d geometry entity
39 
40 // predefined public types
41 public:
43  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Cartesian;
44 
46  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Cube;
47 public:
50  Cube3d();
51  Cube3d(const Point3dData<T>& center, const T halfLength, const ipReal64 alpha, const ipReal64 beta, const ipReal64 chi);
52  Cube3d(const Point3d<T>& center, const T halfLength, const ipReal64 alpha, const ipReal64 beta, const ipReal64 chi);
53  Cube3d(const T xCenter, const T yCenter, const T zCenter, const T halfLength, const ipReal64 alpha, const ipReal64 beta, const ipReal64 chi);
54  ~Cube3d();
56 
57 // methods
58 public:
60  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
61 
63  inline eEntity3dType getEntity3dType() const;
64 
67  inline void setCenter(const Point3dData<T>& centerPt);
68  inline void setCenter(const Point3d<T>& centerPt);
69  inline void setCenter(const T xCenter, const T yCenter, const T zCenter);
70  inline void setHalfLength(const T halfLength);
71  inline void setAlpha(const ipReal64 theta);
72  inline void setBeta(const ipReal64 theta);
73  inline void setChi(const ipReal64 theta);
74  inline T getHalfLength() const;
75  inline T getLength() const;
76  inline ipReal64 getAlpha() const;
77  inline ipReal64 getBeta() const;
78  inline ipReal64 getChi() const;
79  inline T centerX() const;
80  inline T centerY() const;
81  inline T centerZ() const;
82  inline const Point3dData<T>& center() const;
83  inline Point3dData<T>& center();
85 
90  inline Point3dData<T> topLeftFrontCorner() const;
91  inline Point3dData<T> topRightFrontCorner() const;
92  inline Point3dData<T> bottomLeftFrontCorner() const;
93  inline Point3dData<T> bottomRightFrontCorner() const;
94  inline Point3dData<T> topLeftBackCorner() const;
95  inline Point3dData<T> topRightBackCorner() const;
96  inline Point3dData<T> bottomLeftBackCorner() const;
97  inline Point3dData<T> bottomRightBackCorner() const;
99 
100 // attributes
101 protected:
104 
107 
110 
113 
116 
117 };
118 
121 
122 template <typename T>
125 {
126  return g_coordinateSystem3dType;
127 }
128 
129 template <typename T>
130 inline eEntity3dType
132 {
133  return g_entity3dType;
134 }
135 
136 template <typename T>
137 inline void
139 {
140  _centerPt = centerPt;
141 }
142 
143 template <typename T>
144 inline void
146 {
147  _centerPt = centerPt.getCoords();
148 }
149 
150 template <typename T>
151 inline void
152 Cube3d<T>::setCenter(const T xCenter, const T yCenter, const T zCenter)
153 {
154  _centerPt.setCoords(xCenter, yCenter, zCenter);
155 }
156 
157 template <typename T>
158 inline void
159 Cube3d<T>::setHalfLength(const T halfLength)
160 {
161  _halfLength = halfLength;
162 }
163 
164 template <typename T>
165 inline void
167 {
168  _alpha = theta;
169 }
170 
171 template <typename T>
172 inline void
174 {
175  _beta = theta;
176 }
177 
178 template <typename T>
179 inline void
181 {
182  _chi = theta;
183 }
184 
185 template <typename T>
186 inline T
188 {
189  return _centerPt._x;
190 }
191 
192 template <typename T>
193 inline T
195 {
196  return _centerPt._y;
197 }
198 
199 template <typename T>
200 inline T
202 {
203  return _centerPt._z;
204 }
205 
206 template <typename T>
207 inline const Point3dData<T>&
209 {
210  return _centerPt;
211 }
212 
213 template <typename T>
214 inline Point3dData<T>&
216 {
217  return _centerPt;
218 }
219 
220 template <typename T>
221 inline T
223 {
224  return _halfLength;
225 }
226 
227 template <typename T>
228 inline T
230 {
231  return 2*_halfLength;
232 }
233 
234 template <typename T>
235 inline ipReal64
237 {
238  return _alpha;
239 }
240 
241 template <typename T>
242 inline ipReal64
244 {
245  return _beta;
246 }
247 
248 template <typename T>
249 inline ipReal64
251 {
252  return _chi;
253 }
254 
255 template <typename T>
256 inline Point3dData<T>
258 {
259 
260  const ipReal64 cosAlpha = std::cos(_alpha);
261  const ipReal64 sinAlpha = std::sin(_alpha);
262  const ipReal64 cosBeta = std::cos(_beta);
263  const ipReal64 sinBeta = std::sin(_beta);
264  const ipReal64 cosChi = std::cos(_chi);
265  const ipReal64 sinChi = std::sin(_chi);
266 
267  const ipReal64 rxx = cosChi*cosBeta;
268  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
269  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
270  const ipReal64 ryx = sinChi*cosBeta;
271  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
272  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
273  const ipReal64 rzx = -sinBeta;
274  const ipReal64 rzy = cosBeta*sinAlpha;
275  const ipReal64 rzz = cosBeta*cosAlpha;
276 
277  const ipReal64 px = _centerPt._x+_halfLength;
278  const ipReal64 py = _centerPt._y-_halfLength;
279  const ipReal64 pz = _centerPt._z-_halfLength;
280 
281  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
282  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
283  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
284 
285  return Point3dData<T>(x, y, z);
286 }
287 
288 template <typename T>
289 inline Point3dData<T>
291 {
292 
293  const ipReal64 cosAlpha = std::cos(_alpha);
294  const ipReal64 sinAlpha = std::sin(_alpha);
295  const ipReal64 cosBeta = std::cos(_beta);
296  const ipReal64 sinBeta = std::sin(_beta);
297  const ipReal64 cosChi = std::cos(_chi);
298  const ipReal64 sinChi = std::sin(_chi);
299 
300  const ipReal64 rxx = cosChi*cosBeta;
301  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
302  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
303  const ipReal64 ryx = sinChi*cosBeta;
304  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
305  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
306  const ipReal64 rzx = -sinBeta;
307  const ipReal64 rzy = cosBeta*sinAlpha;
308  const ipReal64 rzz = cosBeta*cosAlpha;
309 
310  const ipReal64 px = _centerPt._x+_halfLength;
311  const ipReal64 py = _centerPt._y+_halfLength;
312  const ipReal64 pz = _centerPt._z-_halfLength;
313 
314  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
315  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
316  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
317 
318  return Point3dData<T>(x, y, z);
319 }
320 
321 template <typename T>
322 inline Point3dData<T>
324 {
325 
326  const ipReal64 cosAlpha = std::cos(_alpha);
327  const ipReal64 sinAlpha = std::sin(_alpha);
328  const ipReal64 cosBeta = std::cos(_beta);
329  const ipReal64 sinBeta = std::sin(_beta);
330  const ipReal64 cosChi = std::cos(_chi);
331  const ipReal64 sinChi = std::sin(_chi);
332 
333  const ipReal64 rxx = cosChi*cosBeta;
334  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
335  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
336  const ipReal64 ryx = sinChi*cosBeta;
337  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
338  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
339  const ipReal64 rzx = -sinBeta;
340  const ipReal64 rzy = cosBeta*sinAlpha;
341  const ipReal64 rzz = cosBeta*cosAlpha;
342 
343  const ipReal64 px = _centerPt._x+_halfLength;
344  const ipReal64 py = _centerPt._y-_halfLength;
345  const ipReal64 pz = _centerPt._z+_halfLength;
346 
347  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
348  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
349  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
350 
351  return Point3dData<T>(x, y, z);
352 }
353 
354 template <typename T>
355 inline Point3dData<T>
357 {
358 
359  const ipReal64 cosAlpha = std::cos(_alpha);
360  const ipReal64 sinAlpha = std::sin(_alpha);
361  const ipReal64 cosBeta = std::cos(_beta);
362  const ipReal64 sinBeta = std::sin(_beta);
363  const ipReal64 cosChi = std::cos(_chi);
364  const ipReal64 sinChi = std::sin(_chi);
365 
366  const ipReal64 rxx = cosChi*cosBeta;
367  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
368  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
369  const ipReal64 ryx = sinChi*cosBeta;
370  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
371  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
372  const ipReal64 rzx = -sinBeta;
373  const ipReal64 rzy = cosBeta*sinAlpha;
374  const ipReal64 rzz = cosBeta*cosAlpha;
375 
376  const ipReal64 px = _centerPt._x+_halfLength;
377  const ipReal64 py = _centerPt._y+_halfLength;
378  const ipReal64 pz = _centerPt._z+_halfLength;
379 
380  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
381  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
382  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
383 
384  return Point3dData<T>(x, y, z);
385 }
386 
387 template <typename T>
388 inline Point3dData<T>
390 {
391 
392  const ipReal64 cosAlpha = std::cos(_alpha);
393  const ipReal64 sinAlpha = std::sin(_alpha);
394  const ipReal64 cosBeta = std::cos(_beta);
395  const ipReal64 sinBeta = std::sin(_beta);
396  const ipReal64 cosChi = std::cos(_chi);
397  const ipReal64 sinChi = std::sin(_chi);
398 
399  const ipReal64 rxx = cosChi*cosBeta;
400  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
401  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
402  const ipReal64 ryx = sinChi*cosBeta;
403  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
404  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
405  const ipReal64 rzx = -sinBeta;
406  const ipReal64 rzy = cosBeta*sinAlpha;
407  const ipReal64 rzz = cosBeta*cosAlpha;
408 
409  const ipReal64 px = _centerPt._x-_halfLength;
410  const ipReal64 py = _centerPt._y-_halfLength;
411  const ipReal64 pz = _centerPt._z-_halfLength;
412 
413  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
414  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
415  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
416 
417  return Point3dData<T>(x, y, z);
418 }
419 
420 template <typename T>
421 inline Point3dData<T>
423 {
424 
425  const ipReal64 cosAlpha = std::cos(_alpha);
426  const ipReal64 sinAlpha = std::sin(_alpha);
427  const ipReal64 cosBeta = std::cos(_beta);
428  const ipReal64 sinBeta = std::sin(_beta);
429  const ipReal64 cosChi = std::cos(_chi);
430  const ipReal64 sinChi = std::sin(_chi);
431 
432  const ipReal64 rxx = cosChi*cosBeta;
433  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
434  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
435  const ipReal64 ryx = sinChi*cosBeta;
436  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
437  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
438  const ipReal64 rzx = -sinBeta;
439  const ipReal64 rzy = cosBeta*sinAlpha;
440  const ipReal64 rzz = cosBeta*cosAlpha;
441 
442  const ipReal64 px = _centerPt._x-_halfLength;
443  const ipReal64 py = _centerPt._y+_halfLength;
444  const ipReal64 pz = _centerPt._z-_halfLength;
445 
446  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
447  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
448  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
449 
450  return Point3dData<T>(x, y, z);
451 }
452 
453 template <typename T>
454 inline Point3dData<T>
456 {
457 
458  const ipReal64 cosAlpha = std::cos(_alpha);
459  const ipReal64 sinAlpha = std::sin(_alpha);
460  const ipReal64 cosBeta = std::cos(_beta);
461  const ipReal64 sinBeta = std::sin(_beta);
462  const ipReal64 cosChi = std::cos(_chi);
463  const ipReal64 sinChi = std::sin(_chi);
464 
465  const ipReal64 rxx = cosChi*cosBeta;
466  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
467  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
468  const ipReal64 ryx = sinChi*cosBeta;
469  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
470  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
471  const ipReal64 rzx = -sinBeta;
472  const ipReal64 rzy = cosBeta*sinAlpha;
473  const ipReal64 rzz = cosBeta*cosAlpha;
474 
475  const ipReal64 px = _centerPt._x-_halfLength;
476  const ipReal64 py = _centerPt._y-_halfLength;
477  const ipReal64 pz = _centerPt._z+_halfLength;
478 
479  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
480  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
481  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
482 
483  return Point3dData<T>(x, y, z);
484 }
485 
486 template <typename T>
487 inline Point3dData<T>
489 {
490 
491  const ipReal64 cosAlpha = std::cos(_alpha);
492  const ipReal64 sinAlpha = std::sin(_alpha);
493  const ipReal64 cosBeta = std::cos(_beta);
494  const ipReal64 sinBeta = std::sin(_beta);
495  const ipReal64 cosChi = std::cos(_chi);
496  const ipReal64 sinChi = std::sin(_chi);
497 
498  const ipReal64 rxx = cosChi*cosBeta;
499  const ipReal64 rxy = cosChi*sinBeta*sinAlpha - sinChi*cosAlpha;
500  const ipReal64 rxz = cosChi*sinBeta*cosAlpha + sinChi*sinAlpha;
501  const ipReal64 ryx = sinChi*cosBeta;
502  const ipReal64 ryy = sinChi*sinBeta*sinAlpha + cosChi*cosAlpha;
503  const ipReal64 ryz = sinChi*sinBeta*cosAlpha - cosChi*sinAlpha;
504  const ipReal64 rzx = -sinBeta;
505  const ipReal64 rzy = cosBeta*sinAlpha;
506  const ipReal64 rzz = cosBeta*cosAlpha;
507 
508  const ipReal64 px = _centerPt._x-_halfLength;
509  const ipReal64 py = _centerPt._y+_halfLength;
510  const ipReal64 pz = _centerPt._z+_halfLength;
511 
512  const T x = static_cast<T>(rxx * px + rxy * py + rxz * pz);
513  const T y = static_cast<T>(ryx * px + ryy * py + ryz * pz);
514  const T z = static_cast<T>(rzx * px + rzy * py + rzz * pz);
515 
516  return Point3dData<T>(x, y, z);
517 }
518 
521 
522 } // end of namespace geom
523 } // end of namespace ipsdk
524 
525 #pragma warning (pop)
526 
527 #endif // __IPSDKGEOMETRY_CUBE3D_H__
T getHalfLength() const
access to the cube parameters
Definition: Cube3d.h:222
T centerZ() const
access to the cube parameters
Definition: Cube3d.h:201
Point3dData< T > bottomLeftBackCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:455
Point3dData< T > topLeftFrontCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:257
Point3dData< T > bottomRightBackCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:488
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void setCenter(const Point3dData< T > &centerPt)
access to the cube parameters
Definition: Cube3d.h:138
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
Basic operators used for cube 3d management.
ipReal64 _chi
orientation angle along the z axis
Definition: Cube3d.h:115
Point class associated to cartesian 3d coordinates.
Definition: GeometryEntity3dTypes.h:29
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
ipReal64 _alpha
orientation angle along the x axis
Definition: Cube3d.h:109
Point3dData< T > topRightBackCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:422
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Cube.
Definition: GeometryEntity3dTypes.h:52
const Point3dData< T > & getCoords() const
access to point coordinates
Definition: Point3d.h:142
T centerX() const
access to the cube parameters
Definition: Cube3d.h:187
Point3dData< T > bottomRightFrontCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:356
Definition of import/export macro for library.
void setChi(const ipReal64 theta)
access to the cube parameters
Definition: Cube3d.h:180
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
T centerY() const
access to the cube parameters
Definition: Cube3d.h:194
T getLength() const
access to the cube parameters
Definition: Cube3d.h:229
T _halfLength
half length of a side of the cube
Definition: Cube3d.h:106
ipReal64 getBeta() const
access to the cube parameters
Definition: Cube3d.h:243
const Point3dData< T > & center() const
access to the cube parameters
Definition: Cube3d.h:208
ipReal64 getAlpha() const
access to the cube parameters
Definition: Cube3d.h:236
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
ipReal64 getChi() const
access to the cube parameters
Definition: Cube3d.h:250
Point3dData< T > topRightFrontCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:290
Point3dData< T > _centerPt
center of the cube
Definition: Cube3d.h:103
void setAlpha(const ipReal64 theta)
access to the cube parameters
Definition: Cube3d.h:166
ipReal64 _beta
orientation angle along the y axis
Definition: Cube3d.h:112
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
Cartesian coordinate system.
Definition: GeometryEntity3dTypes.h:76
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Cube3d.h:124
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Cube3d.h:131
Point3dData< T > topLeftBackCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:389
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
3d cube class associated to cartesian 3d coordinates
Definition: Cube3d.h:35
Point3dData< T > bottomLeftFrontCorner() const
compute cube corners coordinates For instance, the topLeftFrontCorner() method calculates the square ...
Definition: Cube3d.h:323
void setBeta(const ipReal64 theta)
access to the cube parameters
Definition: Cube3d.h:173
void setHalfLength(const T halfLength)
access to the cube parameters
Definition: Cube3d.h:159