MRPT  2.0.1
TPoint2D.cpp
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 
10 #include "math-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/TPoint2D.h>
13 #include <mrpt/math/TPoint3D.h>
14 #include <mrpt/math/TPose2D.h>
15 #include <mrpt/math/TPose3D.h>
16 
17 namespace mrpt::math
18 {
19 static_assert(std::is_trivial_v<TPoint2D_data<float>>);
20 static_assert(std::is_trivial_v<TPoint2D_data<double>>);
21 static_assert(std::is_trivially_copyable_v<TPoint2D>);
22 static_assert(std::is_trivially_copyable_v<TPoint2Df>);
23 
24 template <typename T>
26  : TPoint2D_data<T>{static_cast<T>(p.x), static_cast<T>(p.y)}
27 {
28 }
29 
30 template <typename T>
32 {
33 }
34 
35 template <typename T>
37  : TPoint2D_data<T>{static_cast<T>(p.x), static_cast<T>(p.y)}
38 {
39 }
40 
41 template <typename T>
43 {
44  if (this->x < p.x)
45  return true;
46  else if (this->x > p.x)
47  return false;
48  else
49  return this->y < p.y;
50 }
51 
52 template <typename T>
53 void TPoint2D_<T>::fromString(const std::string& s)
54 {
56  if (!m.fromMatlabStringFormat(s))
57  THROW_EXCEPTION("Malformed expression in ::fromString");
58  ASSERTMSG_(
59  m.rows() == 1 && m.cols() == 2, "Wrong size of vector in ::fromString");
60  this->x = m(0, 0);
61  this->y = m(0, 1);
62 }
63 
64 // Explicit instantiations:
65 template struct TPoint2D_<float>;
66 template struct TPoint2D_<double>;
67 } // namespace mrpt::math
double x
X,Y coordinates.
Definition: TPose2D.h:30
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
T x
X,Y coordinates.
Definition: TPoint2D.h:25
constexpr TPoint2D_()
Default constructor.
Definition: TPoint2D.h:41
double x
X,Y,Z, coords.
Definition: TPose3D.h:32
This base provides a set of functions for maths stuff.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
bool fromMatlabStringFormat(const std::string &s, mrpt::optional_ref< std::ostream > dump_errors_here=std::nullopt)
Reads a matrix from a string in Matlab-like format, for example: "[1 0 2; 0 4 -1]" The string must st...
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
Base template for TPoint2D and TPoint2Df.
Definition: TPoint2D.h:32
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:29
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
bool operator<(const COccupancyGridMap2D::TPairLikelihoodIndex &e1, const COccupancyGridMap2D::TPairLikelihoodIndex &e2)
This template class provides the basic functionality for a general 2D any-size, resizable container o...



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020