Main MRPT website > C++ reference for MRPT 1.9.9
CPoint2D.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "poses-precomp.h" // Precompiled headers
11 
12 #include <mrpt/poses/CPoint2D.h>
13 #include <mrpt/poses/CPose2D.h>
15 #include <limits>
16 
17 using namespace mrpt::poses;
18 using namespace mrpt::math;
19 
21 
22 uint8_t CPoint2D::serializeGetVersion() const { return 1; }
24 {
25  out << m_coords[0] << m_coords[1];
26 }
28 {
29  switch (version)
30  {
31  case 0:
32  {
33  // The coordinates:
34  float f;
35  in >> f;
36  m_coords[0] = f;
37  in >> f;
38  m_coords[1] = f;
39  }
40  break;
41  case 1:
42  {
43  // The coordinates:
44  in >> m_coords[0] >> m_coords[1];
45  }
46  break;
47  default:
49  };
50 }
51 
52 /*---------------------------------------------------------------
53 The operator D="this"-b is the pose inverse compounding operator.
54  The resulting pose "D" is the diference between this pose and "b"
55  ---------------------------------------------------------------*/
57 {
58  const double ccos = cos(b.phi());
59  const double ssin = sin(b.phi());
60  const double Ax = x() - b.x();
61  const double Ay = y() - b.y();
62 
63  return CPoint2D(Ax * ccos + Ay * ssin, -Ax * ssin + Ay * ccos);
64 }
65 
67 {
68  for (int i = 0; i < 2; i++)
69  m_coords[i] = std::numeric_limits<double>::quiet_NaN();
70 }
71 
73 {
74  return mrpt::math::TPoint2D(x(), y());
75 }
mrpt::poses::CPoint2D::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CPoint2D.cpp:23
CPoint2D.h
poses-precomp.h
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:25
CPose2D.h
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::poses::CPoint2D::operator-
CPoint2D operator-(const CPose2D &b) const
The operator D="this"-b is the pose inverse compounding operator, the resulting points "D" fulfils: "...
Definition: CPoint2D.cpp:56
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:40
b
GLubyte GLubyte b
Definition: glext.h:6279
mrpt::poses::CPoint2D::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CPoint2D.cpp:27
mrpt::poses::CPoint2D::asTPoint
mrpt::math::TPoint2D asTPoint() const
Definition: CPoint2D.cpp:72
mrpt::math::TPoint2D
Lightweight 2D point.
Definition: lightweight_geom_data.h:42
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
mrpt::poses::CPoint2D::setToNaN
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint2D.cpp:66
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
in
GLuint in
Definition: glext.h:7274
CArchive.h
mrpt::poses::CPoint2D
A class used to store a 2D point.
Definition: CPoint2D.h:35
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST