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>
137 std::ostream& operator<<(std::ostream& o, const CPoint<DERIVEDCLASS>&
p)
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;
#define ASSERT_EQUAL_(__A, __B)
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" ) ...
double x() const
Common members of all points & poses classes.
double & operator[](unsigned int i)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
#define THROW_EXCEPTION(msg)
std::string asString() const
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" ) ...
A numeric matrix of compile-time fixed size.
A base class for representing a point in 2D or 3D.
void AddComponents(const OTHERCLASS &b)
Scalar addition of all coordinates.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
const double & operator[](unsigned int i) const
The base template class for 2D & 3D points and poses.
GLsizei const GLchar ** string
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
size_t size(const MATRIXLIKE &m, const int dim)
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
void getAsVector(mrpt::math::CVectorDouble &v) const
Return the pose or point as a 1x2 or 1x3 vector [x y] or [x y z].
mrpt::math::CVectorDouble getAsVector() const
void operator*=(const double s)
Scalar multiplication.
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
GLubyte GLubyte GLubyte a