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>
106 std::ostream &operator << (std::ostream& o, const CPoint<DERIVEDCLASS>&
p)
108 o <<
"(" <<
p[0] <<
"," <<
p[1];
109 if (
p.is3DPoseOrPoint()) o <<
"," <<
p[2];
115 template <
class DERIVEDCLASS>
118 if (
a.x()<
b.x())
return true;
121 if (!
a.is3DPoseOrPoint())
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;
#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)
#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.
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
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