MRPT  2.0.4
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
mrpt::math::TPointXYZfRGBu8
XYZ point (float) + RGB(u8)
Definition: TPoint3D.h:313
mrpt::math::TPoint3D_
Base template for TPoint3D and TPoint3Df.
Definition: TPoint3D.h:40
TPoint2D.h
mrpt::math::MatrixVectorBase< T, CMatrixDynamic< T > >::fromMatlabStringFormat
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...
Definition: MatrixVectorBase_impl.h:24
mrpt::math::operator<<
mrpt::serialization::CArchive & operator<<(mrpt::serialization::CArchive &s, const CVectorFloat &a)
Definition: math.cpp:626
mrpt::math::TPointXYZfRGBAu8::b
uint8_t b
Definition: TPoint3D.h:333
mrpt::math::TPoint2D_
Base template for TPoint2D and TPoint2Df.
Definition: TPoint2D.h:35
mrpt::math::TPoint3D_data::z
T z
Definition: TPoint3D.h:29
math-precomp.h
TPose2D.h
mrpt::math::TPointXYZfRGBu8::pt
mrpt::math::TPoint3Df pt
Definition: TPoint3D.h:314
mrpt::math::TPose2D::y
double y
Definition: TPose2D.h:30
out
mrpt::vision::TStereoCalibResults out
Definition: chessboard_stereo_camera_calib_unittest.cpp:25
mrpt::math::TPose3D::y
double y
Definition: TPose3D.h:32
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
mrpt::math::TPointXYZfRGBu8::g
uint8_t g
Definition: TPoint3D.h:315
mrpt::math::TPoint3D_::operator<
bool operator<(const TPoint3D_< T > &p) const
Definition: TPoint3D.cpp:44
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:55
mrpt::math::TPoint3D_::TPoint3D_
constexpr TPoint3D_()
Default constructor.
Definition: TPoint3D.h:47
mrpt::math::TPointXYZfRGBAu8::pt
mrpt::math::TPoint3Df pt
Definition: TPoint3D.h:332
mrpt::math::TPointXYZfRGBAu8::r
uint8_t r
Definition: TPoint3D.h:333
mrpt::math::TPose3D::z
double z
Definition: TPose3D.h:32
TPose3D.h
mrpt::math::TPointXYZfRGBu8::r
uint8_t r
Definition: TPoint3D.h:315
mrpt::math::TPoint3D_::fromString
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0....
Definition: TPoint3D.cpp:59
mrpt::math::TPose2D
Lightweight 2D pose.
Definition: TPose2D.h:24
mrpt::math::TPointXYZfRGBAu8
XYZ point (float) + RGBA(u8)
Definition: TPoint3D.h:331
mrpt::math::TPose3D::x
double x
X,Y,Z, coords.
Definition: TPose3D.h:32
mrpt::math::TPose3D
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: TPose3D.h:26
mrpt::math::TPoint2D_data::y
T y
Definition: TPoint2D.h:25
mrpt::math::TPoint3D_data
Trivially copiable underlying data for TPoint3D 1-byte memory packed, no padding].
Definition: TPoint3D.h:27
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
mrpt::math::TPoint3D_data::y
T y
Definition: TPoint3D.h:29
mrpt::math::TPointXYZfRGBAu8::g
uint8_t g
Definition: TPoint3D.h:333
mrpt::math::TPoint2D_data::x
T x
X,Y coordinates.
Definition: TPoint2D.h:25
TPoint3D.h
mrpt::math::TPointXYZfRGBu8::b
uint8_t b
Definition: TPoint3D.h:315
mrpt::math::TPoint3D_data::x
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:29
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:12
mrpt::math::CMatrixDynamic::cols
size_type cols() const
Number of columns in the matrix.
Definition: CMatrixDynamic.h:340
mrpt::math::TPointXYZfRGBAu8::a
uint8_t a
Definition: TPoint3D.h:333
mrpt::math::operator>>
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrixD::Ptr &pObj)
CArchive.h
mrpt::math::CMatrixDynamic
This template class provides the basic functionality for a general 2D any-size, resizable container o...
Definition: CMatrixDynamic.h:40
mrpt::math::CMatrixDynamic::rows
size_type rows() const
Number of rows in the matrix.
Definition: CMatrixDynamic.h:337
mrpt::math::TPose2D::x
double x
X,Y coordinates.
Definition: TPose2D.h:30



Page generated by Doxygen 1.8.18 for MRPT 2.0.4 at Thu Sep 24 07:14:18 UTC 2020