Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
line_segment.h
1 
2 /***************************************************************************
3  * line_segment.h - A line segment
4  *
5  * Created: Thu Oct 02 16:47:39 2008
6  * Copyright 2008 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __GEOMETRY_LINE_SEGMENT_H_
25 #define __GEOMETRY_LINE_SEGMENT_H_
26 
27 #include <geometry/transformable.h>
28 #include <geometry/printable.h>
29 #include <geometry/hom_point.h>
30 #include <geometry/hom_vector.h>
31 
32 namespace fawkes {
33 
35  : public Transformable,
36  public Printable
37 
38 {
39  public:
40  LineSegment(const HomPoint& a, const HomPoint& b);
41  LineSegment(const HomPoint& p, const HomVector& v);
42  LineSegment(const LineSegment& l);
43  virtual ~LineSegment();
44 
45  float length() const;
46 
47  const HomPoint& p1() const;
48  const HomPoint& p2() const;
49 
50  HomPoint project(const HomPoint &p) const;
51 
52  protected:
53  virtual void register_primitives();
54  virtual void post_transform();
55  virtual std::ostream& print(std::ostream& stream) const;
56 
57  private:
58  HomPoint m_p1;
59  HomPoint m_p2;
60 };
61 
62 } // end namespace fawkes
63 
64 #endif /* __GEOMETRY_LINE_SEGMENT_H_ */