MRPT  2.0.1
TPoint3D.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 #include <mrpt/serialization/CArchive.h> // impl of << operator
17 
18 namespace mrpt::math
19 {
20 static_assert(std::is_trivial_v<TPoint3D_data<float>>);
21 static_assert(std::is_trivial_v<TPoint3D_data<double>>);
22 static_assert(std::is_trivially_copyable_v<TPoint3D>);
23 static_assert(std::is_trivially_copyable_v<TPoint3Df>);
24 
25 template <typename T>
27 {
28 }
29 
30 template <typename T>
32  : TPoint3D_data<T>{static_cast<T>(p.x), static_cast<T>(p.y), 0}
33 {
34 }
35 
36 template <typename T>
38  : TPoint3D_data<T>{static_cast<T>(p.x), static_cast<T>(p.y),
39  static_cast<T>(p.z)}
40 {
41 }
42 
43 template <typename T>
45 {
46  if (this->x < p.x)
47  return true;
48  else if (this->x > p.x)
49  return false;
50  else if (this->y < p.y)
51  return true;
52  else if (this->y > p.y)
53  return false;
54  else
55  return this->z < p.z;
56 }
57 
58 template <typename T>
59 void TPoint3D_<T>::fromString(const std::string& s)
60 {
62  if (!m.fromMatlabStringFormat(s))
63  THROW_EXCEPTION("Malformed expression in ::fromString");
64  ASSERTMSG_(
65  m.rows() == 1 && m.cols() == 3, "Wrong size of vector in ::fromString");
66  this->x = m(0, 0);
67  this->y = m(0, 1);
68  this->z = m(0, 2);
69 }
70 
71 // Explicit instantiations:
72 template struct TPoint3D_<float>;
73 template struct TPoint3D_<double>;
74 
77 {
78  return in >> p.pt >> p.r >> p.g >> p.b;
79 }
82 {
83  return out << p.pt << p.r << p.g << p.b;
84 }
85 
88 {
89  return in >> p.pt >> p.r >> p.g >> p.b >> p.a;
90 }
93 {
94  return out << p.pt << p.r << p.g << p.b << p.a;
95 }
96 
97 } // namespace mrpt::math
std::ostream & operator<<(std::ostream &o, const TFTDIDevice &d)
Print out all the information of a FTDI device in textual form.
Trivially copiable underlying data for TPoint3D 1-byte memory packed, no padding].
Definition: TPoint3D.h:26
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
mrpt::math::TPoint3Df pt
Definition: TPoint3D.h:332
CArchive & operator>>(CArchive &a, Foo &f)
double x
X,Y,Z, coords.
Definition: TPose3D.h:32
mrpt::math::TPoint3Df pt
Definition: TPoint3D.h:314
constexpr TPoint3D_()
Default constructor.
Definition: TPoint3D.h:47
This base provides a set of functions for maths stuff.
XYZ point (float) + RGB(u8)
Definition: TPoint3D.h:312
#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...
XYZ point (float) + RGBA(u8)
Definition: TPoint3D.h:330
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
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
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