Image Component Library (ICL)
Point.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLUtils/src/ICLUtils/Point.h **
10 ** Module : ICLUtils **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/Macros.h>
34 #include <ostream>
35 
36 #ifdef ICL_HAVE_IPP
37 #include <ipp.h>
38 #endif
39 
40 namespace icl{
41  namespace utils{
42  #ifndef ICL_HAVE_IPP
43  struct IppiPoint {
46  int x;
48  int y;
49  };
50  #else
51  #endif
52 
54  class Point32f;
57  class ICLUtils_API Point : public IppiPoint{
59  public:
61  static const Point null;
62 
64  Point(){ this->x = 0; this->y = 0; }
65 
67  Point(const Point& p){ this->x = p.x; this->y = p.y; }
68 
70  Point(const Point32f &p);
71 
73  Point(int x,int y){this->x = x;this->y = y;}
74 
76  bool isNull() const { return (*this)==null; }
77 
79  bool operator==(const Point &s) const {return x==s.x && y==s.y;}
80 
82  bool operator!=(const Point &s) const {return x!=s.x || y!=s.y;}
83 
85  Point operator+(const Point &s) const {return Point(x+s.x,y+s.y);}
86 
88  Point operator-(const Point &s) const {return Point(x-s.x,y-s.y);}
89 
91  Point operator*(double d) const { return Point((int)(d*x),(int)(d*y));}
92 
94  Point& operator+=(const Point &s){x+=s.x; y+=s.y; return *this;}
95 
97  Point& operator-=(const Point &s){x-=s.x; y-=s.y; return *this;}
98 
100  Point& operator*=(double d) {x=(int)((double)x*d); y=(int)((double)y*d); return *this;};
101 
103  Point transform(double xfac, double yfac) const{
104  return Point((int)(xfac*x),(int)(yfac*y));
105  }
106 
108  float distanceTo(const Point &p) const;
109 
111  int &operator[](int i) { return i?y:x; }
112 
114  const int &operator[](int i) const { return i?y:x; }
115  };
116 
118  ICLUtils_API std::ostream &operator<<(std::ostream &s, const Point &p);
119 
121  ICLUtils_API std::istream &operator>>(std::istream &s, Point &p);
122 
123 
124  } // namespace utils
125 } // namespace icl
126 
undocument this line if you encounter any issues!
Definition: Any.h:37
Point(const Point &p)
deep copy of a Point
Definition: Point.h:67
Point & operator+=(const Point &s)
Adds another Point inplace.
Definition: Point.h:94
int & operator[](int i)
index based interface (returns i?y:x)
Definition: Point.h:111
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
bool operator==(const Point &s) const
checks if two points are equal
Definition: Point.h:79
Point()
default constructor
Definition: Point.h:64
bool operator!=(const Point &s) const
checks if two points are not equal
Definition: Point.h:82
FixedMatrix< T, V_COLS, M_ROWS_AND_COLS > & operator *=(FixedMatrix< T, V_COLS, M_ROWS_AND_COLS > &v, const FixedMatrix< T, M_ROWS_AND_COLS, M_ROWS_AND_COLS > &m)
Matrix multiplication (inplace)
Definition: FixedMatrix.h:959
ICLUtils_API std::ostream & operator<<(std::ostream &s, const ConfigFile &cf)
Default ostream operator to put a ConfigFile into a stream.
Point(int x, int y)
create a special point
Definition: Point.h:73
ICLUtils_API std::istream & operator>>(std::istream &s, Point &p)
istream operator
Point operator+(const Point &s) const
adds two Points as vectors
Definition: Point.h:85
ICLQt_API ImgQ operator *(const ImgQ &a, const ImgQ &b)
multiplies two images pixel-wise
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
Point transform(double xfac, double yfac) const
transforms the point by element-wise scaling
Definition: Point.h:103
const int & operator[](int i) const
index based interface, const (returns i?y:x)
Definition: Point.h:114
Point operator-(const Point &s) const
substracts two Points as vectors
Definition: Point.h:88
Point & operator-=(const Point &s)
Substacts another Point inplace.
Definition: Point.h:97
bool isNull() const
checks wether the object instance is null, i.e. all elements are zero
Definition: Point.h:76