24 template <
class DERIVEDCLASS>
27 DERIVEDCLASS&
derived() {
return *
static_cast<DERIVEDCLASS*
>(
this); }
30 return *
static_cast<const DERIVEDCLASS*
>(
this);
41 template <
class OTHERCLASS>
46 size_t(OTHERCLASS::is3DPoseOrPoint() ? 3 : 2));
47 for (
int i = 0; i < dims; i++)
49 static_cast<const OTHERCLASS*
>(&
b)->m_coords[i];
64 v[i] = static_cast<const DERIVEDCLASS*>(
this)->m_coords[i];
78 template <
class MATRIX44>
82 out_HM.get_unsafe(0, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
x();
83 out_HM.get_unsafe(1, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
y();
84 if (DERIVEDCLASS::is3DPoseOrPoint())
85 out_HM.get_unsafe(2, 3) =
86 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2];
95 s = (!DERIVEDCLASS::is3DPoseOrPoint())
97 "[%f %f]", static_cast<const DERIVEDCLASS*>(
this)->x(),
98 static_cast<const DERIVEDCLASS*
>(
this)->
y())
100 "[%f %f %f]", static_cast<const DERIVEDCLASS*>(
this)->x(),
101 static_cast<const DERIVEDCLASS*
>(
this)->
y(),
102 static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2]);
119 if (!m.fromMatlabStringFormat(
s))
124 derived().m_coords[i] = m(0, i);
129 return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
137 template <
class DERIVEDCLASS>
138 std::ostream& operator<<(std::ostream& o, const CPoint<DERIVEDCLASS>&
p)
140 o <<
"(" <<
p[0] <<
"," <<
p[1];
141 if (
p.is3DPoseOrPoint()) o <<
"," <<
p[2];
147 template <
class DERIVEDCLASS>
154 if (!
a.is3DPoseOrPoint())
155 return a.y() <
b.y();
156 else if (
a.y() <
b.y())
163 template <
class DERIVEDCLASS>
167 if (p1[i] != p2[i])
return false;
171 template <
class DERIVEDCLASS>
175 if (p1[i] != p2[i])
return true;
const DERIVEDCLASS & derived() const
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[0.02 1.04]" ) ...
void getHomogeneousMatrix(MATRIX44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
double x() const
Common members of all points & poses classes.
double & operator[](unsigned int i)
#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 base class for representing a point in 2D or 3D.
void AddComponents(const OTHERCLASS &b)
Scalar addition of all coordinates.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
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
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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].
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
mrpt::math::CVectorDouble getAsVector() const
void operator*=(const double s)
Scalar multiplication.
GLubyte GLubyte GLubyte a