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 }
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
unsigned char uint8_t
Definition: rptypes.h:41
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
This base provides a set of functions for maths stuff.
GLubyte GLubyte b
Definition: glext.h:6279
A class used to store a 2D point.
Definition: CPoint2D.h:33
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void setToNaN() override
Set all data fields to quiet NaN.
Definition: CPoint2D.cpp:66
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:38
GLuint in
Definition: glext.h:7274
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
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::math::TPoint2D asTPoint() const
Definition: CPoint2D.cpp:72
GLenum GLint x
Definition: glext.h:3538
Lightweight 2D point.
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
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CPoint2D.cpp:23



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020