source: rrlib_geometry/tLine.h @ 24:627bf1924b86

Last change on this file since 24:627bf1924b86 was 24:627bf1924b86, checked in by Tobias Föhst <foehst@…>, 8 years ago

Added streaming operators for rrlib_canvas

File size: 5.6 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    tLine.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-12-27
27 *
28 * \brief   Contains tLine
29 *
30 * \b tLine
31 *
32 * A few words for tLine
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef __rrlib__geometry__tLine_h__
37#define __rrlib__geometry__tLine_h__
38
39#include "rrlib/geometry/tShape.h"
40//----------------------------------------------------------------------
41// External includes (system with <>, local with "")
42//----------------------------------------------------------------------
43#ifdef _LIB_RRLIB_CANVAS_PRESENT_
44#include "rrlib/canvas/tCanvas2D.h"
45#endif
46
47//----------------------------------------------------------------------
48// Internal includes with ""
49//----------------------------------------------------------------------
50
51//----------------------------------------------------------------------
52// Debugging
53//----------------------------------------------------------------------
54
55//----------------------------------------------------------------------
56// Namespace declaration
57//----------------------------------------------------------------------
58namespace rrlib
59{
60namespace geometry
61{
62
63//----------------------------------------------------------------------
64// Forward declarations / typedefs / enums
65//----------------------------------------------------------------------
66
67//----------------------------------------------------------------------
68// Class declaration
69//----------------------------------------------------------------------
70//! Short description of tLine
71/*! A more detailed description of tLine, which
72    Tobias Foehst hasn't done yet !!
73*/
74template < size_t Tdimension, typename TElement = double >
75class tLine : public tShape<Tdimension, TElement>
76{
77
78  typedef geometry::tShape<Tdimension, TElement> tShape;
79
80//----------------------------------------------------------------------
81// Public methods and typedefs
82//----------------------------------------------------------------------
83public:
84
85  typedef typename tShape::tPoint::tElement tParameter;
86
87  tLine();
88  tLine(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
89  tLine(const typename tShape::tPoint &support, const typename tShape::tPoint &second_support);
90
91  inline const typename tShape::tPoint &Support() const
92  {
93    return this->support;
94  }
95
96  inline const math::tVector<Tdimension, TElement> &Direction() const
97  {
98    return this->direction;
99  }
100
101  void Set(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
102
103  const typename tShape::tPoint operator()(tParameter t) const;
104
105  const TElement GetDistanceToPoint(const typename tShape::tPoint &point) const;
106
107  virtual const typename tShape::tPoint GetClosestPoint(const typename tShape::tPoint &reference_point) const;
108
109  const bool GetIntersection(typename tShape::tPoint &intersection_point, const tLine &line) const;
110
111  virtual tLine &Translate(const math::tVector<Tdimension, TElement> &translation);
112  virtual tLine &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
113  virtual tLine &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
114
115//----------------------------------------------------------------------
116// Private fields and methods
117//----------------------------------------------------------------------
118private:
119
120  typename tShape::tPoint support;
121  typename math::tVector<Tdimension, TElement> direction;
122
123  virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const;
124  virtual void UpdateCenterOfGravity(typename tShape::tPoint &center_of_gravity) const;
125
126};
127
128typedef tLine<2, double> tLine2D;
129typedef tLine<3, double> tLine3D;
130
131//----------------------------------------------------------------------
132// Explicit template instantiation
133//----------------------------------------------------------------------
134
135extern template class tLine<2, float>;
136extern template class tLine<3, float>;
137
138extern template class tLine<2, double>;
139extern template class tLine<3, double>;
140
141extern template class tLine<2, int>;
142extern template class tLine<3, int>;
143
144extern template class tLine<2, unsigned int>;
145extern template class tLine<3, unsigned int>;
146
147//----------------------------------------------------------------------
148// Operators for rrlib_canvas
149//----------------------------------------------------------------------
150#ifdef _LIB_RRLIB_CANVAS_PRESENT_
151
152template <typename TElement>
153canvas::tCanvas2D &operator << (canvas::tCanvas2D &canvas, const tLine<2, TElement> &line);
154
155#endif
156
157//----------------------------------------------------------------------
158// End of namespace declaration
159//----------------------------------------------------------------------
160}
161}
162
163
164#include "rrlib/geometry/tLine.hpp"
165
166#endif
Note: See TracBrowser for help on using the repository browser.