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 tPlane.h |
---|
23 | * |
---|
24 | * \author Tobias Foehst |
---|
25 | * |
---|
26 | * \date 2011-01-19 |
---|
27 | * |
---|
28 | * \brief Contains tPlane |
---|
29 | * |
---|
30 | * \b tPlane |
---|
31 | * |
---|
32 | * A few words for tPlane |
---|
33 | * |
---|
34 | */ |
---|
35 | //---------------------------------------------------------------------- |
---|
36 | #ifndef __rrlib__geometry__tPlane_h__ |
---|
37 | #define __rrlib__geometry__tPlane_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 | //---------------------------------------------------------------------- |
---|
55 | namespace rrlib |
---|
56 | { |
---|
57 | namespace geometry |
---|
58 | { |
---|
59 | |
---|
60 | //---------------------------------------------------------------------- |
---|
61 | // Forward declarations / typedefs / enums |
---|
62 | //---------------------------------------------------------------------- |
---|
63 | |
---|
64 | //---------------------------------------------------------------------- |
---|
65 | // Class declaration |
---|
66 | //---------------------------------------------------------------------- |
---|
67 | //! Short description of tPlane |
---|
68 | /*! A more detailed description of tPlane, which |
---|
69 | Tobias Foehst hasn't done yet !! |
---|
70 | */ |
---|
71 | template <size_t Tdimension, typename TElement = double> |
---|
72 | class tPlane : public tShape<3, TElement> |
---|
73 | { |
---|
74 | |
---|
75 | typedef geometry::tShape<Tdimension, TElement> tShape; |
---|
76 | |
---|
77 | //---------------------------------------------------------------------- |
---|
78 | // Public methods and typedefs |
---|
79 | //---------------------------------------------------------------------- |
---|
80 | public: |
---|
81 | |
---|
82 | typedef typename tShape::tPoint::tElement tParameter; |
---|
83 | |
---|
84 | tPlane(); |
---|
85 | tPlane(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &normal); |
---|
86 | tPlane(const typename tShape::tPoint &p1, const typename tShape::tPoint &p2, const typename tShape::tPoint &p3); |
---|
87 | |
---|
88 | inline const typename tShape::tPoint &Support() const |
---|
89 | { |
---|
90 | return this->support; |
---|
91 | } |
---|
92 | |
---|
93 | inline const math::tVector<Tdimension, TElement> &Normal() const |
---|
94 | { |
---|
95 | return this->normal; |
---|
96 | } |
---|
97 | |
---|
98 | void Set(const typename tShape::tPoint &support, const math::tVector<Tdimension, TElement> &normal); |
---|
99 | void Set(const typename tShape::tPoint &p1, const typename tShape::tPoint &p2, const typename tShape::tPoint &p3); |
---|
100 | |
---|
101 | // const typename tShape::tPoint operator()(tParameter t) const; |
---|
102 | |
---|
103 | const TElement GetDistanceToPoint(const typename tShape::tPoint &point) const; |
---|
104 | |
---|
105 | virtual const typename tShape::tPoint GetClosestPoint(const typename tShape::tPoint &reference_point) const; |
---|
106 | |
---|
107 | virtual tPlane &Translate(const math::tVector<Tdimension, TElement> &translation); |
---|
108 | virtual tPlane &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation); |
---|
109 | virtual tPlane &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation); |
---|
110 | |
---|
111 | //---------------------------------------------------------------------- |
---|
112 | // Private fields and methods |
---|
113 | //---------------------------------------------------------------------- |
---|
114 | private: |
---|
115 | |
---|
116 | typename tShape::tPoint support; |
---|
117 | typename math::tVector<Tdimension, TElement> normal; |
---|
118 | |
---|
119 | virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const; |
---|
120 | virtual void UpdateCenterOfGravity(typename tShape::tPoint ¢er_of_gravity) const; |
---|
121 | |
---|
122 | }; |
---|
123 | |
---|
124 | typedef tPlane<3, double> tPlane3D; |
---|
125 | |
---|
126 | //---------------------------------------------------------------------- |
---|
127 | // Explicit template instantiation |
---|
128 | //---------------------------------------------------------------------- |
---|
129 | |
---|
130 | extern template class tPlane<3, float>; |
---|
131 | extern template class tPlane<3, double>; |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | //---------------------------------------------------------------------- |
---|
136 | // End of namespace declaration |
---|
137 | //---------------------------------------------------------------------- |
---|
138 | } |
---|
139 | } |
---|
140 | |
---|
141 | |
---|
142 | #include "rrlib/geometry/tPlane.hpp" |
---|
143 | |
---|
144 | #endif |
---|