IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Vector2d.h
1 // Vector2d.h:
3 // -----------
4 //
14 
15 #ifndef __IPSDKGEOMETRY_VECTOR2D_H__
16 #define __IPSDKGEOMETRY_VECTOR2D_H__
17 
18 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
22 
23 namespace ipsdk {
24 namespace geom {
25 
26 template <typename T>
27 class Point2d;
28 
31 
33 {
34  // declare 2d geometry entity
36 
37 // predefined public types
38 public:
40  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Polar;
41 
43  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_Vector;
44 
45 public:
48  Vector2d();
49  Vector2d(const ipReal64 rho, const ipReal64 theta);
50  template <typename T>
51  Vector2d(const Point2d<T>& ptEnd, const Point2d<T>& ptStart);
52  template <typename T>
53  Vector2d(const Point2dData<T>& ptEnd, const Point2dData<T>& ptStart);
54  template <typename T>
55  explicit Vector2d(const Point2d<T>& ptEnd);
56  template <typename T>
57  explicit Vector2d(const Point2dData<T>& ptEnd);
58  ~Vector2d();
60 
61 // methods
62 public:
64  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
65 
67  inline eEntity2dType getEntity2dType() const;
68 
71  inline void setCoords(const ipReal64 rho, const ipReal64 theta);
72  template <typename T>
73  inline void setCoords(const Point2d<T>& ptEnd, const Point2d<T>& ptStart);
74  template <typename T>
75  void setCoords(const Point2dData<T>& ptEnd, const Point2dData<T>& ptStart);
76  template <typename T>
77  inline void setCoords(const Point2d<T>& ptEnd);
78  template <typename T>
79  void setCoords(const Point2dData<T>& ptEnd);
80  inline void setRho(const ipReal64 rho);
81  inline void setTheta(const ipReal64 theta);
82  inline ipReal64 getRho() const;
83  inline ipReal64 getTheta() const;
85 
88  inline ipReal64 getCosTheta() const;
89  inline ipReal64 getSinTheta() const;
91 
94  inline ipReal64 getX() const;
95  inline ipReal64 getY() const;
97 
100  inline ipReal64 getNx() const;
101  inline ipReal64 getNy() const;
103 
106  Vector2d& operator+=(const Vector2d& vec);
107  Vector2d operator+(const Vector2d& vec) const;
108  Vector2d& operator-=(const Vector2d& vec);
109  Vector2d operator-(const Vector2d& vec) const;
110  Vector2d& operator*=(const ipReal64 value);
111  Vector2d operator*(const ipReal64 value) const;
112  Vector2d& operator/=(const ipReal64 value);
113  Vector2d operator/(const ipReal64 value) const;
115 
116 // attributes
117 protected:
120 
123 
129 };
130 
133 
134 template <typename T>
135 inline
136 Vector2d::Vector2d(const Point2d<T>& ptEnd, const Point2d<T>& ptStart)
137 {
138  setCoords(ptEnd, ptStart);
139 }
140 
141 template <typename T>
142 inline
143 Vector2d::Vector2d(const Point2dData<T>& ptEnd, const Point2dData<T>& ptStart)
144 {
145  setCoords(ptEnd, ptStart);
146 }
147 
148 template <typename T>
149 inline
150 Vector2d::Vector2d(const Point2d<T>& ptEnd)
151 {
152  setCoords(ptEnd);
153 }
154 
155 template <typename T>
156 inline
157 Vector2d::Vector2d(const Point2dData<T>& ptEnd)
158 {
159  setCoords(ptEnd);
160 }
161 
164 {
166 }
167 
168 inline eEntity2dType
170 {
171  return g_entity2dType;
172 }
173 
174 template <typename T>
175 inline void
176 Vector2d::setCoords(const Point2d<T>& ptEnd, const Point2d<T>& ptStart)
177 {
178  setCoords(ptEnd.getCoords(), ptStart.getCoords());
179 }
180 
181 template <typename T>
182 inline void
184 {
185  setCoords(ptEnd.getCoords());
186 }
187 
188 inline void
189 Vector2d::setCoords(const ipReal64 rho, const ipReal64 theta)
190 {
191  setRho(rho);
192  setTheta(theta);
193 }
194 
195 inline void
197 {
198  _rho = rho;
199 }
200 
201 inline void
203 {
204  _theta = math::centerModulo(theta, 2*M_PI);
205  _cosTheta = std::cos(_theta);
206  _sinTheta = std::sin(_theta);
207 }
208 
209 inline ipReal64
211 {
212  return _rho;
213 }
214 
215 inline ipReal64
217 {
218  return _theta;
219 }
220 
221 inline ipReal64
223 {
224  return _cosTheta;
225 }
226 
227 inline ipReal64
229 {
230  return _sinTheta;
231 }
232 
233 inline ipReal64
235 {
236  return math::polarToXCartesian<ipReal64>(_rho, _cosTheta, _sinTheta);
237 }
238 
239 inline ipReal64
241 {
242  return math::polarToYCartesian<ipReal64>(_rho, _cosTheta, _sinTheta);
243 }
244 
245 inline ipReal64
247 {
248  return math::polarToXCartesian<ipReal64>(1.0, _cosTheta, _sinTheta);
249 }
250 
251 inline ipReal64
253 {
254  return math::polarToYCartesian<ipReal64>(1.0, _cosTheta, _sinTheta);
255 }
256 
259 
260 } // end of namespace geom
261 } // end of namespace ipsdk
262 
263 #endif // __IPSDKGEOMETRY_VECTOR2D_H__
ipReal64 getRho() const
access to point coordinates
Definition: Vector2d.h:210
void setCoords(const ipReal64 rho, const ipReal64 theta)
access to point coordinates
Definition: Vector2d.h:189
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
ipReal64 getSinTheta() const
access to computation intermediate
Definition: Vector2d.h:228
Vector.
Definition: GeometryEntity2dTypes.h:42
Point class associated to cartesian 2d coordinates.
Definition: GeometryEntity2dTypes.h:28
ipReal64 _cosTheta
computation intermediate
Definition: Vector2d.h:126
Utility functions for vectors 2d management.
void setRho(const ipReal64 rho)
access to point coordinates
Definition: Vector2d.h:196
ipReal64 getTheta() const
access to point coordinates
Definition: Vector2d.h:216
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
Basic operators used for vector 2d management.
ipReal64 getY() const
retrieve cartesian components of vector
Definition: Vector2d.h:240
static const eEntity2dType::domain g_entity2dType
type associated to entity
Definition: Vector2d.h:43
ipReal64 getNx() const
retrieve unit normed cartesian components of vector
Definition: Vector2d.h:246
Utility functions used to handle angles 2d.
ipReal64 getX() const
retrieve cartesian components of vector
Definition: Vector2d.h:234
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: Vector2d.h:169
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: Vector2d.h:163
ipReal64 _rho
rho coordinate of point
Definition: Vector2d.h:119
Polar coordinate system.
Definition: GeometryEntity2dTypes.h:80
ipReal64 _theta
theta coordinate of point
Definition: Vector2d.h:122
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
Vector class associated to polar 2d coordinates.
Definition: Vector2d.h:32
ipReal64 _sinTheta
computation intermediate
Definition: Vector2d.h:127
static const eCoordinateSystem2dType::domain g_coordinateSystem2dType
coordinate system associated to entity
Definition: Vector2d.h:40
const Point2dData< T > & getCoords() const
access to point coordinates
Definition: Point2d.h:139
boost::numeric::ublas::bounded_vector< ipReal64, 2 > Vector2d
2d vector type associated to library
Definition: LinearAlgebraTypes.h:39
ipReal64 getCosTheta() const
access to computation intermediate
Definition: Vector2d.h:222
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
void setTheta(const ipReal64 theta)
access to point coordinates
Definition: Vector2d.h:202
ipReal64 getNy() const
retrieve unit normed cartesian components of vector
Definition: Vector2d.h:252
IPSDK_FORCEINLINE ipReal64 centerModulo(const ipReal64 angle, const ipReal64 modulo)
function allowing to compute centered modulo of an angle
Definition: Angles.h:57