Image Component Library (ICL)
Line.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 : ICLCore/src/ICLCore/Line.h **
10 ** Module : ICLCore **
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/Point.h>
35 #include <ICLUtils/Rect.h>
36 #include <vector>
37 
38 namespace icl{
39  namespace core{
41 
49  public:
51  static const Line null;
52 
54 
59  start(start),end(end){}
60 
62 
66  Line(utils::Point start, float angle, float length);
67 
69 
72  Line operator+(const utils::Point &p) const { return Line(start+p,end+p); }
73 
75 
78  Line operator-(const utils::Point &p) const { return Line(start-p,end-p); }
79 
81 
82  float length() const;
83 
85  utils::Point findClosestPoint(const utils::Point &p) const;
86 
88 
90  inline float getMinDist(const utils::Point &p) const{
91  return findClosestPoint(p).distanceTo(p);
92  }
93 
95 
100  bool intersects(const core::Line &other, utils::Point32f *p=0,
101  float *dstr=0, float *dsts=0) const;
102 
103 
105 
113  std::vector<utils::Point> sample( const utils::Rect &limits=utils::Rect::null ) const;
114 
116  void swap() { utils::Point x=start; start=end; end=x; }
117 
120 
123  };
124 
126  ICLCore_API std::ostream &operator<<(std::ostream &s, const Line &l);
127 
129  ICLCore_API std::istream &operator>>(std::istream &s, Line &l);
130 
131  } // namespace core
132 }
133 
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLCore_API std::istream & operator>>(std::istream &s, format &f)
puts a string representation of format into the given stream
ICLCore_API std::ostream & operator<<(std::ostream &s, const format &f)
puts a string representation of format into the given stream
utils::Point start
start point of this line
Definition: Line.h:119
static const Rect null
null Rect is w=0, h=0, x=0, y=0
Definition: Rect.h:99
The ICLs abstract line class describing a line from Point "start" to Point "end".
Definition: Line.h:48
float getMinDist(const utils::Point &p) const
returns the minimum distance of the line to a given point
Definition: Line.h:90
void swap()
swaps the lines start and end point internally
Definition: Line.h:116
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
utils::Point end
end point of this line
Definition: Line.h:122
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
Line(utils::Point start=utils::Point::null, utils::Point end=utils::Point::null)
Creates a new line from point "start" to point "end".
Definition: Line.h:57
static const Point null
null Point is x=0, y=0
Definition: Point.h:61
Line operator+(const utils::Point &p) const
translates a line by a given vector
Definition: Line.h:72
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
Line operator-(const utils::Point &p) const
translates a line by a given vector (negative direction)
Definition: Line.h:78
#define ICLCore_API
Definition: CompatMacros.h:174