IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Vector3d.h
1 // Vector3d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_VECTOR3D_H__
16 #define __IPSDKGEOMETRY_VECTOR3D_H__
17 
18 #include <IPSDKGeometry/Entity/3d/BaseTypedGeometryEntity3d.h>
22 
23 namespace ipsdk {
24 namespace geom {
25 
26 template <typename T>
27 class Point3d;
28 
31 
33 {
34  // declare 3d geometry entity
36 
37 // predefined public types
38 public:
40  static const eCoordinateSystem3dType::domain g_coordinateSystem3dType = eCoordinateSystem3dType::eCS3DT_Spherical;
41 
43  static const eEntity3dType::domain g_entity3dType = eEntity3dType::eE3DT_Vector;
44 
45 public:
48  Vector3d();
49  Vector3d(const ipReal64 rho, const ipReal64 theta, const ipReal64 phi);
50  template <typename T>
51  Vector3d(const Point3d<T>& ptEnd, const Point3d<T>& ptStart);
52  template <typename T>
53  Vector3d(const Point3dData<T>& ptEnd, const Point3dData<T>& ptStart);
54  template <typename T>
55  explicit Vector3d(const Point3d<T>& ptEnd);
56  template <typename T>
57  explicit Vector3d(const Point3dData<T>& ptEnd);
58  ~Vector3d();
60 
61 // methods
62 public:
64  inline eCoordinateSystem3dType getCoordinateSystem3dType() const;
65 
67  inline eEntity3dType getEntity3dType() const;
68 
71  void setCoords(const ipReal64 rho, const ipReal64 theta, const ipReal64 phi);
72  template <typename T>
73  inline void setCoords(const Point3d<T>& ptEnd, const Point3d<T>& ptStart);
74  template <typename T>
75  void setCoords(const Point3dData<T>& ptEnd, const Point3dData<T>& ptStart);
76  template <typename T>
77  inline void setCoords(const Point3d<T>& ptEnd);
78  template <typename T>
79  void setCoords(const Point3dData<T>& ptEnd);
80  inline void setRho(const ipReal64 rho);
81  inline void setTheta(const ipReal64 theta);
82  inline void setPhi(const ipReal64 phi);
83  inline ipReal64 getRho() const;
84  inline ipReal64 getTheta() const;
85  inline ipReal64 getPhi() const;
87 
90  inline ipReal64 getCosTheta() const;
91  inline ipReal64 getSinTheta() const;
92  inline ipReal64 getCosPhi() const;
93  inline ipReal64 getSinPhi() const;
95 
98  inline ipReal64 getX() const;
99  inline ipReal64 getY() const;
100  inline ipReal64 getZ() const;
102 
105  inline ipReal64 getNx() const;
106  inline ipReal64 getNy() const;
107  inline ipReal64 getNz() const;
109 
112  Vector3d& operator+=(const Vector3d& vec);
113  Vector3d operator+(const Vector3d& vec) const;
114  Vector3d& operator-=(const Vector3d& vec);
115  Vector3d operator-(const Vector3d& vec) const;
116  Vector3d& operator*=(const ipReal64 value);
117  Vector3d operator*(const ipReal64 value) const;
118  Vector3d& operator/=(const ipReal64 value);
119  Vector3d operator/(const ipReal64 value) const;
121 
122 // attributes
123 protected:
126 
129 
132 
140 };
141 
144 
145 template <typename T>
146 inline
147 Vector3d::Vector3d(const Point3d<T>& ptEnd, const Point3d<T>& ptStart)
148 {
149  setCoords(ptEnd, ptStart);
150 }
151 
152 template <typename T>
153 inline
154 Vector3d::Vector3d(const Point3dData<T>& ptEnd, const Point3dData<T>& ptStart)
155 {
156  setCoords(ptEnd, ptStart);
157 }
158 
159 template <typename T>
160 inline
161 Vector3d::Vector3d(const Point3d<T>& ptEnd)
162 {
163  setCoords(ptEnd);
164 }
165 
166 template <typename T>
167 inline
168 Vector3d::Vector3d(const Point3dData<T>& ptEnd)
169 {
170  setCoords(ptEnd);
171 }
172 
175 {
177 }
178 
179 inline eEntity3dType
181 {
182  return g_entity3dType;
183 }
184 
185 template <typename T>
186 inline void
187 Vector3d::setCoords(const Point3d<T>& ptEnd, const Point3d<T>& ptStart)
188 {
189  setCoords(ptEnd.getCoords(), ptStart.getCoords());
190 }
191 
192 template <typename T>
193 inline void
195 {
196  setCoords(ptEnd.getCoords());
197 }
198 
199 inline void
201 {
202  _rho = rho;
203 }
204 
205 inline void
207 {
208  _theta = math::centerModulo(theta, 2*M_PI);
209  _cosTheta = std::cos(_theta);
210  _sinTheta = std::sin(_theta);
211 }
212 
213 inline void
215 {
216  _phi = math::centerModulo(phi, 2*M_PI);
217  _cosPhi = std::cos(_phi);
218  _sinPhi = std::sin(_phi);
219 }
220 
221 inline ipReal64
223 {
224  return _rho;
225 }
226 
227 inline ipReal64
229 {
230  return _theta;
231 }
232 
233 inline ipReal64
235 {
236  return _phi;
237 }
238 
239 inline ipReal64
241 {
242  return _cosTheta;
243 }
244 
245 inline ipReal64
247 {
248  return _sinTheta;
249 }
250 
251 inline ipReal64
253 {
254  return _cosPhi;
255 }
256 
257 inline ipReal64
259 {
260  return _sinPhi;
261 }
262 
263 inline ipReal64
265 {
266  return math::sphericalToXCartesian<ipReal64>(_rho, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
267 }
268 
269 inline ipReal64
271 {
272  return math::sphericalToYCartesian<ipReal64>(_rho, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
273 }
274 
275 inline ipReal64
277 {
278  return math::sphericalToZCartesian<ipReal64>(_rho, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
279 }
280 
281 inline ipReal64
283 {
284  return math::sphericalToXCartesian<ipReal64>(1.0, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
285 }
286 
287 inline ipReal64
289 {
290  return math::sphericalToYCartesian<ipReal64>(1.0, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
291 }
292 
293 inline ipReal64
295 {
296  return math::sphericalToZCartesian<ipReal64>(1.0, _cosTheta, _sinTheta, _cosPhi, _sinPhi);
297 }
298 
301 
302 } // end of namespace geom
303 } // end of namespace ipsdk
304 
305 #endif // __IPSDKGEOMETRY_VECTOR3D_H__
Vector.
Definition: GeometryEntity3dTypes.h:42
ipReal64 _cosTheta
computation intermediate
Definition: Vector3d.h:135
ipReal64 _theta
theta coordinate of point
Definition: Vector3d.h:128
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
static const eCoordinateSystem3dType::domain g_coordinateSystem3dType
coordinate system associated to entity
Definition: Vector3d.h:40
eCoordinateSystem3dType
Enumerate describing coordinate system 3d type.
Definition: GeometryEntity3dTypes.h:74
ipReal64 getPhi() const
access to point coordinates
Definition: Vector3d.h:234
Point class associated to cartesian 3d coordinates.
Definition: GeometryEntity3dTypes.h:29
ipReal64 getNz() const
retrieve unit normed cartesian components of vector
Definition: Vector3d.h:294
static const eEntity3dType::domain g_entity3dType
type associated to entity
Definition: Vector3d.h:43
#define IPSDK_DECLARE_GEOMETRY_ENTITY_3D(libraryName, className)
Macro allowing to declare a geometry entity 3d.
Definition: GeometryEntity3dHdrMacros.h:131
ipReal64 _sinPhi
computation intermediate
Definition: Vector3d.h:138
IPSDKGEOMETRY_API Point2d< T > operator*(const ipReal64 value, const Point2d< T > &pt)
arithmetic operators on point
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
ipReal64 getCosPhi() const
access to computation intermediate
Definition: Vector3d.h:252
const Point3dData< T > & getCoords() const
access to point coordinates
Definition: Point3d.h:142
ipReal64 getX() const
retrieve cartesian components of vector
Definition: Vector3d.h:264
ipReal64 _cosPhi
computation intermediate
Definition: Vector3d.h:137
Vector class associated to spherical 3d coordinates.
Definition: Vector3d.h:32
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Spherical coordinate system.
Definition: GeometryEntity3dTypes.h:78
eCoordinateSystem3dType getCoordinateSystem3dType() const
method allowing to retrieve coordinate system 3d type
Definition: Vector3d.h:174
ipReal64 getZ() const
retrieve cartesian components of vector
Definition: Vector3d.h:276
eEntity3dType getEntity3dType() const
method allowing to retrieve entity 3d type
Definition: Vector3d.h:180
ipReal64 getCosTheta() const
access to computation intermediate
Definition: Vector3d.h:240
ipReal64 getSinTheta() const
access to computation intermediate
Definition: Vector3d.h:246
ipReal64 getTheta() const
access to point coordinates
Definition: Vector3d.h:228
void setRho(const ipReal64 rho)
access to point coordinates
Definition: Vector3d.h:200
ipReal64 getSinPhi() const
access to computation intermediate
Definition: Vector3d.h:258
eEntity3dType
Enumerate describing entity 3d type.
Definition: GeometryEntity3dTypes.h:38
Utility functions used to handle angles 3d.
ipReal64 _sinTheta
computation intermediate
Definition: Vector3d.h:136
ipReal64 _phi
phi coordinate of point
Definition: Vector3d.h:131
void setTheta(const ipReal64 theta)
access to point coordinates
Definition: Vector3d.h:206
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity3d.h:27
boost::numeric::ublas::bounded_vector< ipReal64, 3 > Vector3d
3d vector type associated to library
Definition: LinearAlgebraTypes.h:42
Basic operators used for vector 3d management.
void setCoords(const ipReal64 rho, const ipReal64 theta, const ipReal64 phi)
access to point coordinates
ipReal64 getNx() const
retrieve unit normed cartesian components of vector
Definition: Vector3d.h:282
Utility functions for vectors 3d management.
void setPhi(const ipReal64 phi)
access to point coordinates
Definition: Vector3d.h:214
Lightweight structure used to store Point3d data.
Definition: GeometryEntity3dTypes.h:27
ipReal64 _rho
rho coordinate of point
Definition: Vector3d.h:125
ipReal64 getRho() const
access to point coordinates
Definition: Vector3d.h:222
ipReal64 getNy() const
retrieve unit normed cartesian components of vector
Definition: Vector3d.h:288
IPSDK_FORCEINLINE ipReal64 centerModulo(const ipReal64 angle, const ipReal64 modulo)
function allowing to compute centered modulo of an angle
Definition: Angles.h:57
ipReal64 getY() const
retrieve cartesian components of vector
Definition: Vector3d.h:270