Image Component Library (ICL)
Point32f.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/Point32f.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/CompatMacros.h>
34 #include <ICLUtils/ClippedCast.h>
35 #include <ICLUtils/Point.h>
36 
37 namespace icl{
38  namespace utils{
39 
42  public:
43 
45  float x;
46 
48  float y;
49 
51  static const Point32f null;
52 
54  Point32f() :x(0.0f), y(0.0f){}
55 
57  Point32f(const Point32f& p):x(p.x),y(p.y){}
58 
60  Point32f(float x,float y):x(x),y(y){}
61 
63  Point32f(const Point &p):x(p.x),y(p.y){}
64 
66  bool isNull() const { return (*this)==null; }
67 
69  bool operator==(const Point32f &s) const {return x==s.x && y==s.y;}
70 
72  bool operator!=(const Point32f &s) const {return x!=s.x || y!=s.y;}
73 
75  Point32f operator+(const Point32f &s) const {return Point32f(x+s.x,y+s.y);}
76 
78  Point32f operator-(const Point32f &s) const {return Point32f(x-s.x,y-s.y);}
79 
81  Point32f operator*(double d) const { return Point32f(d*x,d*y);}
82 
84  Point32f& operator+=(const Point32f &s){x+=s.x; y+=s.y; return *this;}
85 
87  Point32f& operator-=(const Point32f &s){x-=s.x; y-=s.y; return *this;}
88 
90  Point32f& operator*=(double d) {x*=d; y*=d; return *this; }
91 
93  Point32f transform(double xfac, double yfac) const{
94  return Point32f(xfac*x,yfac*y);
95  }
96 
98  float distanceTo(const Point32f &p) const;
99 
101  bool inTriangle(const utils::Point32f &v1,
102  const utils::Point32f &v2,
103  const utils::Point32f &v3) const;
104 
106 
113  float norm(float p=2) const;
114 
116 
120  float l = norm(); x/=l; y/=l; return *this;
121  }
122 
124 
126  return Point32f(*this).normalize();
127  }
128 
130  float &operator[](int i) { return i?y:x; }
131 
133  const float &operator[](int i) const { return i?y:x; }
134  };
135 
137  ICLUtils_API std::ostream &operator<<(std::ostream &s, const Point32f &p);
138 
140  ICLUtils_API std::istream &operator>>(std::istream &s, Point32f &p);
141 
142 
143  } // namespace utils
144 } // namespace icl
145 
float & operator[](int i)
index based interface (returns i?y:x)
Definition: Point32f.h:130
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API core::Img< T > norm(const core::Img< T > &image)
normalize an images range to [0,255]
float y
y position of this point
Definition: Point32f.h:48
Point32f & operator+=(const Point32f &s)
Adds another Point32f inplace.
Definition: Point32f.h:84
#define ICLUtils_API
this macros are important for creating dll's
Definition: CompatMacros.h:171
Point32f(const Point32f &p)
deep copy of a Point
Definition: Point32f.h:57
Point32f transform(double xfac, double yfac) const
transforms the point by element-wise scaling
Definition: Point32f.h:93
Point32f normalized() const
returns a normalized version of this Point
Definition: Point32f.h:125
bool operator==(const Point32f &s) const
checks if two points are equal
Definition: Point32f.h:69
Point32f operator+(const Point32f &s) const
adds two Points as vectors
Definition: Point32f.h:75
const float & operator[](int i) const
index based interface, const (returns i?y:x)
Definition: Point32f.h:133
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
Point32f & operator-=(const Point32f &s)
Substacts another Point32f inplace.
Definition: Point32f.h:87
ICLUtils_API std::ostream & operator<<(std::ostream &s, const ConfigFile &cf)
Default ostream operator to put a ConfigFile into a stream.
Point32f operator-(const Point32f &s) const
substracts two Point32fs as vectors
Definition: Point32f.h:78
Point32f & normalize()
normalized this 2D vector to length=1;
Definition: Point32f.h:119
ICLUtils_API std::istream & operator>>(std::istream &s, Point &p)
istream operator
Point32f(float x, float y)
create a special point
Definition: Point32f.h:60
Point32f(const Point &p)
craete a point by a given interger point
Definition: Point32f.h:63
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
float x
x position of this point
Definition: Point32f.h:45
bool operator!=(const Point32f &s) const
checks if two points are not equal
Definition: Point32f.h:72
Point32f()
default constructor
Definition: Point32f.h:54
bool isNull() const
checks wether the object instance is null, i.e. all elements are zero
Definition: Point32f.h:66