source: rrlib_geometry/tLine.h @ 3:1b43b0dab355

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

Adapted to changes in rrlib_math rev. 22

File size: 5.2 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) AG Robotersysteme TU Kaiserslautern
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(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
85  tLine(const typename tShape::tPoint &support, const typename tShape::tPoint &second_support);
86
87  inline const typename tShape::tPoint &Support() const
88  {
89    return this->support;
90  }
91
92  inline const math::tVector<Tdimension, TElement> &Direction() const
93  {
94    return this->direction;
95  }
96
97  void Set(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &direction);
98
99  const typename tShape::tPoint operator()(tParameter t) const;
100
101  const TElement GetDistanceToPoint(const typename tShape::tPoint &point) const;
102
103  virtual const typename tShape::tPoint GetNearestPoint(const typename tShape::tPoint &reference_point) const;
104
105  const bool GetIntersection(typename tShape::tPoint &intersection_point, const tLine &line) const;
106
107  virtual tLine &Translate(const math::tVector<Tdimension, TElement> &translation);
108  virtual tLine &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
109  virtual tLine &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
110
111//----------------------------------------------------------------------
112// Private fields and methods
113//----------------------------------------------------------------------
114private:
115
116  typename tShape::tPoint support;
117  typename math::tVector<Tdimension, TElement> direction;
118
119  virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const;
120  virtual void UpdateCenterOfGravity(typename tShape::tPoint &center_of_gravity) const;
121
122};
123
124typedef tLine<2, double> tLine2D;
125typedef tLine<3, double> tLine3D;
126
127//----------------------------------------------------------------------
128// Explicit template instantiation
129//----------------------------------------------------------------------
130
131extern template class tLine<2, float>;
132extern template class tLine<3, float>;
133
134extern template class tLine<2, double>;
135extern template class tLine<3, double>;
136
137extern template class tLine<2, int>;
138extern template class tLine<3, int>;
139
140extern template class tLine<2, unsigned int>;
141extern template class tLine<3, unsigned int>;
142
143//----------------------------------------------------------------------
144// End of namespace declaration
145//----------------------------------------------------------------------
146}
147}
148
149
150#include "rrlib/geometry/tLine.hpp"
151
152#endif
Note: See TracBrowser for help on using the repository browser.