Go to the documentation of this file.
26 template <
class DERIVEDCLASS>
29 DERIVEDCLASS&
derived() {
return *
static_cast<DERIVEDCLASS*
>(
this); }
32 return *
static_cast<const DERIVEDCLASS*
>(
this);
43 template <
class OTHERCLASS>
48 size_t(OTHERCLASS::is3DPoseOrPoint() ? 3 : 2));
49 for (
int i = 0; i < dims; i++)
51 static_cast<const OTHERCLASS*
>(&
b)->m_coords[i];
66 v[i] =
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
80 template <
class MATRIX44>
84 out_HM.get_unsafe(0, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
x();
85 out_HM.get_unsafe(1, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
y();
86 if (DERIVEDCLASS::is3DPoseOrPoint())
87 out_HM.get_unsafe(2, 3) =
88 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2];
97 s = (!DERIVEDCLASS::is3DPoseOrPoint())
99 "[%f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
100 static_cast<const DERIVEDCLASS*
>(
this)->
y())
102 "[%f %f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
103 static_cast<const DERIVEDCLASS*
>(
this)->
y(),
104 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2]);
121 if (!m.fromMatlabStringFormat(
s))
126 derived().m_coords[i] = m(0, i);
131 return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
139 template <
class DERIVEDCLASS>
142 o <<
"(" <<
p[0] <<
"," <<
p[1];
143 if (
p.is3DPoseOrPoint()) o <<
"," <<
p[2];
149 template <
class DERIVEDCLASS>
156 if (!
a.is3DPoseOrPoint())
157 return a.y() <
b.y();
158 else if (
a.y() <
b.y())
165 template <
class DERIVEDCLASS>
169 if (p1[i] != p2[i])
return false;
173 template <
class DERIVEDCLASS>
177 if (p1[i] != p2[i])
return true;
double & operator[](unsigned int i)
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" )
A base class for representing a point in 2D or 3D.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
std::string asString() const
void getAsVector(mrpt::math::CVectorDouble &v) const
Return the pose or point as a 1x2 or 1x3 vector [x y] or [x y z].
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" )
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define THROW_EXCEPTION(msg)
The base template class for 2D & 3D points and poses.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
mrpt::math::CVectorDouble getAsVector() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double x() const
Common members of all points & poses classes.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
const DERIVEDCLASS & derived() const
void AddComponents(const OTHERCLASS &b)
Scalar addition of all coordinates.
void operator*=(const double s)
Scalar multiplication.
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
GLsizei const GLchar ** string
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z]
void getHomogeneousMatrix(MATRIX44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
const double & operator[](unsigned int i) const
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at mié 12 jul 2023 10:03:34 CEST | |