IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Line2d.h
1 // Line2d.h:
3 // ---------
4 //
21 
22 #ifndef __IPSDKGEOMETRY_LINE2D_H__
23 #define __IPSDKGEOMETRY_LINE2D_H__
24 
26 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h>
29 
30 namespace ipsdk {
31 namespace geom {
32 
33 template <typename T>
34 struct Point2dData;
35 template <typename T>
36 class Point2d;
37 class Vector2d;
38 
41 
43 {
44  // declare 2d geometry entity
46 
47 // predefined public types
48 public:
50  static const eCoordinateSystem2dType::domain g_coordinateSystem2dType = eCoordinateSystem2dType::eCS2DT_Polar;
51 
53  static const eEntity2dType::domain g_entity2dType = eEntity2dType::eE2DT_Line;
54 
55 public:
58  Line2d();
59  Line2d(const ipReal64 rho, const ipReal64 theta);
60  template <typename T>
61  Line2d(const Point2d<T>& pt0, const Point2d<T>& pt1);
62  template <typename T>
63  Line2d(const Point2dData<T>& pt0, const Point2dData<T>& pt1);
64  template <typename T>
65  Line2d(const Point2d<T>& pt, const Vector2d& normal);
66  template <typename T>
67  Line2d(const Point2dData<T>& pt, const Vector2d& normal);
68  ~Line2d();
70 
71 // methods
72 public:
74  inline eCoordinateSystem2dType getCoordinateSystem2dType() const;
75 
77  inline eEntity2dType getEntity2dType() const;
78 
81  inline void setCoords(const ipReal64 rho, const ipReal64 theta);
82  template <typename T>
83  inline void setCoords(const Point2d<T>& pt0, const Point2d<T>& pt1);
84  template <typename T>
85  void setCoords(const Point2dData<T>& pt0, const Point2dData<T>& pt1);
86  template <typename T>
87  inline void setCoords(const Point2d<T>& pt, const Vector2d& normal);
88  template <typename T>
89  void setCoords(const Point2dData<T>& pt, const Vector2d& normal);
90  inline void setRho(const ipReal64 rho);
91  inline void setTheta(const ipReal64 theta);
92  inline ipReal64 getRho() const;
93  inline ipReal64 getTheta() const;
95 
97  Vector2d getDirection() const;
98 
100  Vector2d getNormal() const;
101 
103  Point2dData<ipReal64> getNearestPointFromOrigin() const;
104 
107  template <typename T>
108  inline ipReal64 distance(const Point2d<T>& pt) const;
109  template <typename T>
110  ipReal64 distance(const Point2dData<T>& pt) const;
112 
117  template <typename T>
118  inline ipReal64 signedDistance(const Point2d<T>& pt) const;
119  template <typename T>
120  ipReal64 signedDistance(const Point2dData<T>& pt) const;
122 
125  inline ipReal64 getCosTheta() const;
126  inline ipReal64 getSinTheta() const;
128 
131  Line2d& operator+=(const Vector2d& vec);
132  Line2d operator+(const Vector2d& vec) const;
133  Line2d& operator-=(const Vector2d& vec);
134  Line2d operator-(const Vector2d& vec) const;
136 
137 // attributes
138 protected:
141 
144 
150 };
151 
154 
155 template <typename T>
156 inline
157 Line2d::Line2d(const Point2d<T>& pt0, const Point2d<T>& pt1)
158 {
159  setCoords(pt0, pt1);
160 }
161 
162 template <typename T>
163 inline
164 Line2d::Line2d(const Point2dData<T>& pt0, const Point2dData<T>& pt1)
165 {
166  setCoords(pt0, pt1);
167 }
168 
169 template <typename T>
170 inline
171 Line2d::Line2d(const Point2d<T>& pt, const Vector2d& normal)
172 {
173  setCoords(pt, normal);
174 }
175 
176 template <typename T>
177 inline
178 Line2d::Line2d(const Point2dData<T>& pt, const Vector2d& normal)
179 {
180  setCoords(pt, normal);
181 }
182 
185 {
187 }
188 
189 inline eEntity2dType
191 {
192  return g_entity2dType;
193 }
194 
195 inline void
196 Line2d::setCoords(const ipReal64 rho, const ipReal64 theta)
197 {
198  setRho(rho);
199  setTheta(theta);
200 }
201 
202 template <typename T>
203 inline void
204 Line2d::setCoords(const Point2d<T>& pt0, const Point2d<T>& pt1)
205 {
206  setCoords(pt0.getCoords(), pt1.getCoords());
207 }
208 
209 template <typename T>
210 inline void
211 Line2d::setCoords(const Point2d<T>& pt, const Vector2d& normal)
212 {
213  setCoords(pt.getCoords(), normal);
214 }
215 
216 inline void
218 {
219  _rho = rho;
220 }
221 
222 inline void
224 {
225  _theta = math::centerModulo(theta, 2*M_PI);
226  _cosTheta = std::cos(_theta);
227  _sinTheta = std::sin(_theta);
228 }
229 
230 inline ipReal64
232 {
233  return _rho;
234 }
235 
236 inline ipReal64
238 {
239  return _theta;
240 }
241 
242 template <typename T>
243 inline ipReal64
244 Line2d::distance(const Point2d<T>& pt) const
245 {
246  return distance(pt.getCoords());
247 }
248 
249 template <typename T>
250 inline ipReal64
252 {
253  return std::abs(signedDistance(pt));
254 }
255 
256 template <typename T>
257 inline ipReal64
259 {
260  return signedDistance(pt.getCoords());
261 }
262 
263 inline ipReal64
265 {
266  return _cosTheta;
267 }
268 
269 inline ipReal64
271 {
272  return _sinTheta;
273 }
274 
277 
278 } // end of namespace geom
279 } // end of namespace ipsdk
280 
281 #endif // __IPSDKGEOMETRY_LINE2D_H__
ipReal64 getCosTheta() const
access to computation intermediate
Definition: Line2d.h:264
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
void setTheta(const ipReal64 theta)
access to line coordinates
Definition: Line2d.h:223
Point class associated to cartesian 2d coordinates.
Definition: GeometryEntity2dTypes.h:28
ipReal64 signedDistance(const Point2d< T > &pt) const
retrieve signed orthogonal distance between point and line (positive value stands for points located ...
Definition: Line2d.h:258
ipReal64 getRho() const
access to line coordinates
Definition: Line2d.h:231
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: Line2d.h:184
Operators associated to line 2d entities.
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
Line.
Definition: GeometryEntity2dTypes.h:62
Utility functions used to handle angles 2d.
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
Polar coordinate system.
Definition: GeometryEntity2dTypes.h:80
IPSDKGEOMETRY_API ipReal64 distance(const Point2d< T > &pt1, const Point2d< T > &pt2)
compute euclidian distance between two points
ipReal64 _rho
rho coordinate of line
Definition: Line2d.h:140
ipReal64 getTheta() const
access to line coordinates
Definition: Line2d.h:237
ipReal64 _cosTheta
computation intermediate
Definition: Line2d.h:147
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
ipReal64 getSinTheta() const
access to computation intermediate
Definition: Line2d.h:270
2d line associated to polar coordinates
Definition: Line2d.h:42
#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: Line2d.h:190
static const eEntity2dType::domain g_entity2dType
type associated to entity
Definition: Line2d.h:53
ipReal64 _theta
theta coordinate of line
Definition: Line2d.h:143
void setCoords(const ipReal64 rho, const ipReal64 theta)
access to line coordinates
Definition: Line2d.h:196
Vector class associated to polar 2d coordinates.
Definition: Vector2d.h:32
ipReal64 distance(const Point2d< T > &pt) const
retrieve orthogonal distance between point and line
Definition: Line2d.h:244
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
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
void setRho(const ipReal64 rho)
access to line coordinates
Definition: Line2d.h:217
static const eCoordinateSystem2dType::domain g_coordinateSystem2dType
coordinate system associated to entity
Definition: Line2d.h:50
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
ipReal64 _sinTheta
computation intermediate
Definition: Line2d.h:148
IPSDK_FORCEINLINE PackT abs(const PackT &in)
returns the absolute value of a pack
Definition: abs.h:41
IPSDK_FORCEINLINE ipReal64 centerModulo(const ipReal64 angle, const ipReal64 modulo)
function allowing to compute centered modulo of an angle
Definition: Angles.h:57