MRPT  1.9.9
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-2019, 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 struct TPoint2D;
31 struct TPoint3D;
32 struct TPose2D;
33 struct TPose3D;
34 struct TPose3DQuat;
35 struct TPoseOrPoint;
36 struct TTwist2D;
37 struct TTwist3D;
38 template <class T>
39 class CQuaternion;
40 
41 struct TSegment2D;
42 struct TSegment3D;
43 struct TLine2D;
44 struct TLine3D;
45 class TPolygon3D;
46 class TPolygon2D;
47 struct TObject3D;
48 struct TObject2D;
49 
50 namespace internal
51 {
52 /** Provided for STL and matrices/vectors compatibility */
53 template <typename Derived>
55 {
56  constexpr std::size_t rows() const { return Derived::static_size; }
57  constexpr std::size_t cols() const { return 1; }
58  constexpr std::size_t size() const { return Derived::static_size; }
59 
60  /** throws if attempted to resize to incorrect length */
61  void resize(std::size_t n) { ASSERT_EQUAL_(n, Derived::static_size); }
62 };
63 } // namespace internal
64 
65 /** Text streaming function */
66 template <
67  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
68  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
69 std::ostream& operator<<(std::ostream& o, const PoseOrPoint& p)
70 {
71  o << p.asString();
72  return o;
73 }
74 
75 /** Binary streaming function */
76 template <
77  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
78  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
80  mrpt::serialization::CArchive& in, PoseOrPoint& o)
81 {
82  for (int i = 0; i < o.static_size; i++) in >> o[i];
83  return in;
84 }
85 
86 /** Binary streaming function */
87 template <
88  class PoseOrPoint, typename = std::enable_if_t<std::is_base_of_v<
89  mrpt::math::TPoseOrPoint, PoseOrPoint>>>
91  mrpt::serialization::CArchive& out, const PoseOrPoint& o)
92 {
93  for (int i = 0; i < o.static_size; i++) out << o[i];
94  return out;
95 }
96 
97 /**
98  * Object type identifier for TPoint2D or TPoint3D.
99  * \sa TObject2D,TObject3D
100  */
101 static constexpr unsigned char GEOMETRIC_TYPE_POINT = 0;
102 /**
103  * Object type identifier for TSegment2D or TSegment3D.
104  * \sa TObject2D,TObject3D
105  */
106 static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT = 1;
107 /**
108  * Object type identifier for TLine2D or TLine3D.
109  * \sa TObject2D,TObject3D
110  */
111 static constexpr unsigned char GEOMETRIC_TYPE_LINE = 2;
112 /**
113  * Object type identifier for TPolygon2D or TPolygon3D.
114  * \sa TObject2D,TObject3D
115  */
116 static constexpr unsigned char GEOMETRIC_TYPE_POLYGON = 3;
117 /**
118  * Object type identifier for TPlane.
119  * \sa TObject3D
120  */
121 static constexpr unsigned char GEOMETRIC_TYPE_PLANE = 4;
122 /**
123  * Object type identifier for empty TObject2D or TObject3D.
124  * \sa TObject2D,TObject3D
125  */
126 static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED = 255;
127 
128 } // namespace mrpt::math
constexpr std::size_t rows() const
Definition: TPoseOrPoint.h:56
static constexpr unsigned char GEOMETRIC_TYPE_POLYGON
Object type identifier for TPolygon2D or TPolygon3D.
Definition: TPoseOrPoint.h:116
Base type of all TPoseXX and TPointXX classes in mrpt::math.
Definition: TPoseOrPoint.h:24
GLenum GLsizei n
Definition: glext.h:5136
void resize(std::size_t n)
throws if attempted to resize to incorrect length
Definition: TPoseOrPoint.h:61
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:101
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
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:121
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:21
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:137
static constexpr unsigned char GEOMETRIC_TYPE_UNDEFINED
Object type identifier for empty TObject2D or TObject3D.
Definition: TPoseOrPoint.h:126
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
Definition: TPose3DQuat.h:19
constexpr std::size_t size() const
Definition: TPoseOrPoint.h:58
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
Provided for STL and matrices/vectors compatibility.
Definition: TPoseOrPoint.h:54
mrpt::vision::TStereoCalibResults out
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
Definition: math.cpp:627
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:23
GLuint in
Definition: glext.h:7391
Lightweight 2D pose.
Definition: TPose2D.h:22
constexpr std::size_t cols() const
Definition: TPoseOrPoint.h:57
static constexpr unsigned char GEOMETRIC_TYPE_SEGMENT
Object type identifier for TSegment2D or TSegment3D.
Definition: TPoseOrPoint.h:106
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:44
Lightweight 3D point.
Definition: TPoint3D.h:90
Lightweight 2D point.
Definition: TPoint2D.h:31
GLfloat GLfloat p
Definition: glext.h:6398
static constexpr unsigned char GEOMETRIC_TYPE_LINE
Object type identifier for TLine2D or TLine3D.
Definition: TPoseOrPoint.h:111
2D polygon, inheriting from std::vector<TPoint2D>.
Definition: TPolygon2D.h:21
3D polygon, inheriting from std::vector<TPoint3D>
Definition: TPolygon3D.h:18
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 1.9.9 Git: e47402b84 Wed Oct 23 01:09:07 2019 +0200 at miƩ oct 23 01:10:13 CEST 2019