MRPT  2.0.4
TPoseOrPoint.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/core/exceptions.h>
13 #include <mrpt/typemeta/TTypeName.h> // Used in all derived classes
14 #include <iosfwd> // std::ostream
15 #include <stdexcept>
16 #include <type_traits>
17 
18 namespace mrpt::math
19 {
20 /** Base type of all TPoseXX and TPointXX classes in mrpt::math.
21  * Useful for type traits. No virtual methods at all.
22  * \ingroup geometry_grp
23  */
25 {
26 };
27 
28 /** Forward declarations of all mrpt::math classes related to poses and points
29  */
30 template <typename T>
31 struct TPoint2D_;
34 
35 template <typename T>
36 struct TPoint3D_;
39 
40 struct TPose2D;
41 struct TPose3D;
42 struct TPose3DQuat;
43 struct TPoseOrPoint;
44 struct TTwist2D;
45 struct TTwist3D;
46 template <class T>
47 class CQuaternion;
48 
49 struct TSegment2D;
50 struct TSegment3D;
51 struct TLine2D;
52 struct TLine3D;
53 class TPolygon3D;
54 class TPolygon2D;
55 struct TObject3D;
56 struct TObject2D;
57 struct TPlane;
58 
59 namespace internal
60 {
61 /** Provided for STL and matrices/vectors compatibility */
62 template <typename Derived>
64 {
65  constexpr std::size_t rows() const { return Derived::static_size; }
66  constexpr std::size_t cols() const { return 1; }
67  constexpr std::size_t size() const { return Derived::static_size; }
68 
69  /** throws if attempted to resize to incorrect length */
70  void resize(std::size_t n) { ASSERT_EQUAL_(n, Derived::static_size); }
71 };
72 } // namespace internal
73 
74 /** Text streaming function */
75 template <
76  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
77  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
78 std::ostream& operator<<(std::ostream& o, const PoseOrPoint& p)
79 {
80  o << p.asString();
81  return o;
82 }
83 
84 /** Binary streaming function */
85 template <
86  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
87  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
89  mrpt::serialization::CArchive& in, PoseOrPoint& o)
90 {
91  for (int i = 0; i < o.static_size; i++) in >> o[i];
92  return in;
93 }
94 
95 /** Binary streaming function */
96 template <
97  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
98  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
100  mrpt::serialization::CArchive& out, const PoseOrPoint& o)
101 {
102  for (int i = 0; i < o.static_size; i++) out << o[i];
103  return out;
104 }
105 
106 /**
107  * Object type identifier for TPoint2D or TPoint3D.
108  * \sa TObject2D,TObject3D
109  */
110 static constexpr unsigned char GEOMETRIC_TYPE_POINT = 0;
111 /**
112  * Object type identifier for TSegment2D or TSegment3D.
113  * \sa TObject2D,TObject3D
114  */
115 static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT = 1;
116 /**
117  * Object type identifier for TLine2D or TLine3D.
118  * \sa TObject2D,TObject3D
119  */
120 static constexpr unsigned char GEOMETRIC_TYPE_LINE = 2;
121 /**
122  * Object type identifier for TPolygon2D or TPolygon3D.
123  * \sa TObject2D,TObject3D
124  */
125 static constexpr unsigned char GEOMETRIC_TYPE_POLYGON = 3;
126 /**
127  * Object type identifier for TPlane.
128  * \sa TObject3D
129  */
130 static constexpr unsigned char GEOMETRIC_TYPE_PLANE = 4;
131 /**
132  * Object type identifier for empty TObject2D or TObject3D.
133  * \sa TObject2D,TObject3D
134  */
135 static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED = 255;
136 
137 } // namespace mrpt::math
constexpr std::size_t rows() const
Definition: TPoseOrPoint.h:65
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
Definition: TPoseOrPoint.h:125
Base type of all TPoseXX and TPointXX classes in mrpt::math.
Definition: TPoseOrPoint.h:24
void resize(std::size_t n)
throws if attempted to resize to incorrect length
Definition: TPoseOrPoint.h:70
Standard type for storing any lightweight 2D type.
Definition: TObject2D.h:24
static constexpr unsigned char GEOMETRIC_TYPE_POINT
Object type identifier for TPoint2D or TPoint3D.
Definition: TPoseOrPoint.h:110
Standard object for storing any 3D lightweight object.
Definition: TObject3D.h:25
3D twist: 3D velocity vector (vx,vy,vz) + angular velocity (wx,wy,wz)
Definition: TTwist3D.h:18
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
Definition: TTwist2D.h:19
static constexpr unsigned char GEOMETRIC_TYPE_PLANE
Object type identifier for TPlane.
Definition: TPoseOrPoint.h:130
This base provides a set of functions for maths stuff.
2D segment, consisting of two points.
Definition: TSegment2D.h:20
3D segment, consisting of two points.
Definition: TSegment3D.h:20
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:137
3D Plane, represented by its equation
Definition: TPlane.h:22
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
Definition: TPoseOrPoint.h:135
Base template for TPoint2D and TPoint2Df.
Definition: TPoint2D.h:32
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
Definition: TPose3DQuat.h:19
constexpr std::size_t size() const
Definition: TPoseOrPoint.h:67
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
Provided for STL and matrices/vectors compatibility.
Definition: TPoseOrPoint.h:63
mrpt::vision::TStereoCalibResults out
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
Definition: math.cpp:626
Base template for TPoint3D and TPoint3Df.
Definition: TPoint3D.h:37
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:24
Lightweight 2D pose.
Definition: TPose2D.h:22
constexpr std::size_t cols() const
Definition: TPoseOrPoint.h:66
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
Definition: TPoseOrPoint.h:115
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:44
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
Definition: TPoseOrPoint.h:120
2D polygon, inheriting from std::vector<TPoint2D>.
Definition: TPolygon2D.h:21
3D polygon, inheriting from std::vector<TPoint3D>
Definition: TPolygon3D.h:20
3D line, represented by a base point and a director vector.
Definition: TLine3D.h:19
2D line without bounds, represented by its equation .
Definition: TLine2D.h:19



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020