source: rrlib_geometry/tLineSegment.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    tLineSegment.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-12-27
27 *
28 * \brief   Contains tLineSegment
29 *
30 * \b tLineSegment
31 *
32 * A few words for tLineSegment
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef __rrlib__geometry__tLineSegment_h__
37#define __rrlib__geometry__tLineSegment_h__
38
39#ifndef __rrlib__geometry__tLine_h__
40#error Invalid include directive. Try #include "rrlib/geometry/tLine.h" instead.
41#endif
42
43//----------------------------------------------------------------------
44// External includes (system with <>, local with "")
45//----------------------------------------------------------------------
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 tLineSegment
71/*! A more detailed description of tLineSegment, which
72    Tobias Foehst hasn't done yet !!
73*/
74template < size_t Tdimension, typename TElement = double >
75class tLineSegment : public tLine<Tdimension, TElement>
76{
77
78  typedef geometry::tLine<Tdimension, TElement> tLine;
79  typedef geometry::tShape<Tdimension, TElement> tShape;
80
81//----------------------------------------------------------------------
82// Public methods and typedefs
83//----------------------------------------------------------------------
84public:
85
86  tLineSegment();
87  tLineSegment(const typename tShape::tPoint &begin, const typename tShape::tPoint &end);
88
89  inline const typename tShape::tPoint &Begin() const
90  {
91    return this->Support();
92  }
93  inline const typename tShape::tPoint &End() const
94  {
95    return this->end;
96  }
97
98  void Set(const typename tShape::tPoint &begin, const typename tShape::tPoint &end);
99
100  inline const typename tShape::tPoint &MidPoint()
101  {
102    return this->CenterOfGravity();
103  }
104
105  inline const TElement Length() const
106  {
107    return (this->Begin() - this->End()).Length();
108  }
109
110  virtual const typename tShape::tPoint GetClosestPoint(const typename tShape::tPoint &reference_point) const;
111
112  virtual tLineSegment &Translate(const math::tVector<Tdimension, TElement> &translation);
113  virtual tLineSegment &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
114  virtual tLineSegment &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
115
116//----------------------------------------------------------------------
117// Private fields and methods
118//----------------------------------------------------------------------
119private:
120
121  typename tShape::tPoint end;
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 tLineSegment<2, double> tLineSegment2D;
129typedef tLineSegment<3, double> tLineSegment3D;
130
131//----------------------------------------------------------------------
132// Explicit template instantiation
133//----------------------------------------------------------------------
134
135extern template class tLineSegment<2, float>;
136extern template class tLineSegment<3, float>;
137
138extern template class tLineSegment<2, double>;
139extern template class tLineSegment<3, double>;
140
141extern template class tLineSegment<2, int>;
142extern template class tLineSegment<3, int>;
143
144extern template class tLineSegment<2, unsigned int>;
145extern template class tLineSegment<3, unsigned int>;
146
147//----------------------------------------------------------------------
148// End of namespace declaration
149//----------------------------------------------------------------------
150}
151}
152
153
154#include "rrlib/geometry/tLineSegment.hpp"
155
156#endif
Note: See TracBrowser for help on using the repository browser.