25 template <
class DERIVEDCLASS>
35 template <
class OTHERCLASS>
39 for (
int i=0;i<dims;i++)
40 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i]+=
static_cast<const OTHERCLASS*
>(&b)->m_coords[i];
47 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i] *= s;
55 v[i] =
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
66 out_HM.get_unsafe(0,3)=
static_cast<const DERIVEDCLASS*
>(
this)->
x();
67 out_HM.get_unsafe(1,3)=
static_cast<const DERIVEDCLASS*
>(
this)->
y();
68 if (DERIVEDCLASS::is3DPoseOrPoint())
69 out_HM.get_unsafe(2,3)=
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2];
77 s = (!DERIVEDCLASS::is3DPoseOrPoint()) ?
78 mrpt::format(
"[%f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
static_cast<const DERIVEDCLASS*
>(
this)->
y()) :
79 mrpt::format(
"[%f %f %f]",
static_cast<const DERIVEDCLASS*
>(
this)->x(),
static_cast<const DERIVEDCLASS*
>(
this)->
y(),
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2]);
90 if (!m.fromMatlabStringFormat(s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
94 static_cast<DERIVEDCLASS*
>(
this)->m_coords[i] = m.get_unsafe(0,i);
97 inline const double &
operator[](
unsigned int i)
const {
return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i]; }
98 inline double &
operator[](
unsigned int i) {
return static_cast<DERIVEDCLASS*
>(
this)->m_coords[i]; }
105 template <
class DERIVEDCLASS>
108 o <<
"(" << p[0] <<
"," << p[1];
115 template <
class DERIVEDCLASS>
118 if (a.
x()<b.
x())
return true;
123 else if (a.
y()<b.
y())
125 else return a[2]<b[2];
129 template <
class DERIVEDCLASS>
133 if (p1[i]!=p2[i])
return false;
137 template <
class DERIVEDCLASS>
141 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.
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
double & operator[](unsigned int i)
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.
static bool is3DPoseOrPoint()
Return true for poses or points with a Z component, false otherwise.
double x() const
Common members of all points & poses classes.
#define ASSERT_EQUAL_(__A, __B)
#define THROW_EXCEPTION(msg)
size_t size(const MATRIXLIKE &m, int dim)
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 > &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 BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.