source: rrlib_geometry/tLine.h @ 17:3daa58ced492

Last change on this file since 17:3daa58ced492 was 17:3daa58ced492, checked in by Tobias Föhst <foehst@…>, 9 years ago

Merged with changes from rrlab

File size: 5.2 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
44//----------------------------------------------------------------------
45// Internal includes with ""
46//----------------------------------------------------------------------
47
48//----------------------------------------------------------------------
49// Debugging
50//----------------------------------------------------------------------
51
52//----------------------------------------------------------------------
53// Namespace declaration
54//----------------------------------------------------------------------
55namespace rrlib
56{
57namespace geometry
58{
59
60//----------------------------------------------------------------------
61// Forward declarations / typedefs / enums
62//----------------------------------------------------------------------
63
64//----------------------------------------------------------------------
65// Class declaration
66//----------------------------------------------------------------------
67//! Short description of tLine
68/*! A more detailed description of tLine, which
69    Tobias Foehst hasn't done yet !!
70*/
71template < size_t Tdimension, typename TElement = double >
72class tLine : public tShape<Tdimension, TElement>
73{
74
75  typedef geometry::tShape<Tdimension, TElement> tShape;
76
77//----------------------------------------------------------------------
78// Public methods and typedefs
79//----------------------------------------------------------------------
80public:
81
82  typedef typename tShape::tPoint::tElement tParameter;
83
84  tLine();
85  tLine(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
86  tLine(const typename tShape::tPoint &support, const typename tShape::tPoint &second_support);
87
88  inline const typename tShape::tPoint &Support() const
89  {
90    return this->support;
91  }
92
93  inline const math::tVector<Tdimension, TElement> &Direction() const
94  {
95    return this->direction;
96  }
97
98  void Set(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
99
100  const typename tShape::tPoint operator()(tParameter t) const;
101
102  const TElement GetDistanceToPoint(const typename tShape::tPoint &point) const;
103
104  virtual const typename tShape::tPoint GetClosestPoint(const typename tShape::tPoint &reference_point) const;
105
106  const bool GetIntersection(typename tShape::tPoint &intersection_point, const tLine &line) const;
107
108  virtual tLine &Translate(const math::tVector<Tdimension, TElement> &translation);
109  virtual tLine &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
110  virtual tLine &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
111
112//----------------------------------------------------------------------
113// Private fields and methods
114//----------------------------------------------------------------------
115private:
116
117  typename tShape::tPoint support;
118  typename math::tVector<Tdimension, TElement> direction;
119
120  virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const;
121  virtual void UpdateCenterOfGravity(typename tShape::tPoint &center_of_gravity) const;
122
123};
124
125typedef tLine<2, double> tLine2D;
126typedef tLine<3, double> tLine3D;
127
128//----------------------------------------------------------------------
129// Explicit template instantiation
130//----------------------------------------------------------------------
131
132extern template class tLine<2, float>;
133extern template class tLine<3, float>;
134
135extern template class tLine<2, double>;
136extern template class tLine<3, double>;
137
138extern template class tLine<2, int>;
139extern template class tLine<3, int>;
140
141extern template class tLine<2, unsigned int>;
142extern template class tLine<3, unsigned int>;
143
144//----------------------------------------------------------------------
145// End of namespace declaration
146//----------------------------------------------------------------------
147}
148}
149
150
151#include "rrlib/geometry/tLine.hpp"
152
153#endif
Note: See TracBrowser for help on using the repository browser.