source: rrlib_geometry/tPoint.h @ 60:a22756932ab5

Last change on this file since 60:a22756932ab5 was 60:a22756932ab5, checked in by Tobias Föhst <foehst@…>, 6 years ago

Added and updated license information

File size: 4.8 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 modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (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 along
18// with this program; if not, write to the Free Software Foundation, Inc.,
19// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20//
21//----------------------------------------------------------------------
22/*!\file    tPoint.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-12-26
27 *
28 * \brief   Contains tPoint
29 *
30 * \b tPoint
31 *
32 * A few words for tPoint
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef __rrlib__geometry__tPoint_h__
37#define __rrlib__geometry__tPoint_h__
38
39#include "rrlib/math/tVector.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 tPoint
71/*! A more detailed description of tPoint, which
72    Tobias Foehst hasn't done yet !!
73*/
74template <size_t Tdimension, typename TElement = double>
75class tPoint : public math::tVector<Tdimension, TElement, math::vector::Cartesian>
76{
77  typedef math::tVector<Tdimension, TElement, math::vector::Cartesian> tVector;
78
79//----------------------------------------------------------------------
80// Public methods and typedefs
81//----------------------------------------------------------------------
82public:
83
84  inline tPoint() : tVector() {}
85  inline tPoint(const tPoint &other) : tVector(*reinterpret_cast<const tVector *>(&other)) {}
86
87  inline tPoint(const tVector &vector) : tVector(vector) {}
88
89  template <typename ... TValues>
90  explicit inline tPoint(TValues... values) : tVector(values...) {}
91
92  inline tPoint &operator = (const tPoint &other)
93  {
94    return static_cast<tPoint &>(tVector::operator=(other));
95  }
96
97  inline tPoint &operator = (const tVector &vector)
98  {
99    return static_cast<tPoint &>(tVector::operator=(vector));
100  }
101
102  template <typename TOtherElement>
103  inline tPoint &operator = (const math::tVector<Tdimension, TOtherElement> &other)
104  {
105    return static_cast<tPoint &>(tVector::operator=(other));
106  }
107
108};
109
110typedef tPoint<2, double> tPoint2D;
111typedef tPoint<3, double> tPoint3D;
112
113//----------------------------------------------------------------------
114// Explicit template instantiation
115//----------------------------------------------------------------------
116
117extern template class tPoint<2, float>;
118extern template class tPoint<3, float>;
119
120extern template class tPoint<2, double>;
121extern template class tPoint<3, double>;
122
123extern template class tPoint<2, int>;
124extern template class tPoint<3, int>;
125
126extern template class tPoint<2, unsigned int>;
127extern template class tPoint<3, unsigned int>;
128
129//----------------------------------------------------------------------
130// Operators for rrlib_canvas
131//----------------------------------------------------------------------
132#ifdef _LIB_RRLIB_CANVAS_PRESENT_
133
134template <typename TElement>
135canvas::tCanvas2D &operator << (canvas::tCanvas2D &canvas, const tPoint<2, TElement> &point)
136{
137  canvas.DrawPoint(point);
138
139  return canvas;
140}
141
142#endif
143
144//----------------------------------------------------------------------
145// End of namespace declaration
146//----------------------------------------------------------------------
147}
148}
149
150#endif
Note: See TracBrowser for help on using the repository browser.