26 template <
class DERIVEDCLASS>
37 template <
class OTHERCLASS>
42 size_t(OTHERCLASS::is3DPoseOrPoint() ? 3 : 2));
43 for (
int i = 0; i < dims; i++)
44 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i] +=
45 static_cast<const OTHERCLASS*
>(&
b)->m_coords[i];
52 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i] *=
s;
60 v[i] =
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
77 out_HM.get_unsafe(0, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
x();
78 out_HM.get_unsafe(1, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
y();
79 if (DERIVEDCLASS::is3DPoseOrPoint())
80 out_HM.get_unsafe(2, 3) =
81 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2];
90 s = (!DERIVEDCLASS::is3DPoseOrPoint())
92 "[%f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
93 static_cast<const DERIVEDCLASS*
>(
this)->
y())
95 "[%f %f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
96 static_cast<const DERIVEDCLASS*
>(
this)->
y(),
97 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2]);
114 if (!m.fromMatlabStringFormat(
s))
119 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i] = m.get_unsafe(0, i);
124 return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
128 return static_cast<DERIVEDCLASS*
>(
this)->m_coords[i];
136 template <
class DERIVEDCLASS>
139 o <<
"(" <<
p[0] <<
"," <<
p[1];
140 if (
p.is3DPoseOrPoint()) o <<
"," <<
p[2];
146 template <
class DERIVEDCLASS>
153 if (!
a.is3DPoseOrPoint())
154 return a.y() <
b.y();
155 else if (
a.y() <
b.y())
162 template <
class DERIVEDCLASS>
166 if (p1[i] != p2[i])
return false;
170 template <
class DERIVEDCLASS>
174 if (p1[i] != p2[i])
return true;
A numeric matrix of compile-time fixed size.
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
A base class for representing a point in 2D or 3D.
double & operator[](unsigned int i)
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
void AddComponents(const OTHERCLASS &b)
Scalar addition of all coordinates.
std::string asString() const
const double & operator[](unsigned int i) const
mrpt::math::CVectorDouble getAsVector() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" )
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 asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" )
void operator*=(const double s)
Scalar multiplication.
The base template class for 2D & 3D points and poses.
double x() const
Common members of all points & poses classes.
GLubyte GLubyte GLubyte a
GLsizei const GLchar ** string
#define ASSERT_EQUAL_(__A, __B)
#define THROW_EXCEPTION(msg)
size_t size(const MATRIXLIKE &m, const int dim)
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z]
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.