Main MRPT website > C++ reference for MRPT 1.5.7
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-2017, 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 "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/poses/CPoint2D.h>
13 #include <mrpt/poses/CPose2D.h>
14 #include <mrpt/utils/CStream.h>
15 #include <limits>
16 
17 using namespace mrpt::poses;
18 using namespace mrpt::utils;
19 using namespace mrpt::math;
20 
22 
23 /*---------------------------------------------------------------
24  Implements the writing to a CStream capability of
25  CSerializable objects
26  ---------------------------------------------------------------*/
27 void CPoint2D::writeToStream(mrpt::utils::CStream &out, int *version) const
28 {
29  if (version)
30  *version = 1;
31  else
32  {
33  // The coordinates:
34  out << m_coords[0] << m_coords[1];
35  }
36 }
37 
38 /*---------------------------------------------------------------
39  Implements the reading from a CStream capability of
40  CSerializable objects
41  ---------------------------------------------------------------*/
43 {
44  switch(version)
45  {
46  case 0:
47  {
48  // The coordinates:
49  float f;
50  in >> f; m_coords[0]=f;
51  in >> f; m_coords[1]=f;
52  } break;
53  case 1:
54  {
55  // The coordinates:
56  in >> m_coords[0] >> m_coords[1];
57  } break;
58  default:
60  };
61 }
62 
63 /*---------------------------------------------------------------
64 The operator D="this"-b is the pose inverse compounding operator.
65  The resulting pose "D" is the diference between this pose and "b"
66  ---------------------------------------------------------------*/
68 {
69  const double ccos = cos(b.phi());
70  const double ssin = sin(b.phi());
71  const double Ax = x()-b.x();
72  const double Ay = y()-b.y();
73 
74  return CPoint2D( Ax * ccos + Ay * ssin, -Ax * ssin + Ay * ccos );
75 }
76 
78 {
79  for (int i=0;i<2;i++)
80  m_coords[i] = std::numeric_limits<double>::quiet_NaN();
81 }
82 
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
Definition: CPoint2D.cpp:42
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
GLubyte GLubyte b
Definition: glext.h:5575
int version
Definition: mrpt_jpeglib.h:898
A class used to store a 2D point.
Definition: CPoint2D.h:36
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:36
GLuint in
Definition: glext.h:6301
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:67
GLenum GLint GLint y
Definition: glext.h:3516
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLenum GLint x
Definition: glext.h:3516
void setToNaN() MRPT_OVERRIDE
Set all data fields to quiet NaN.
Definition: CPoint2D.cpp:77



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019