23 template <
class DERIVEDCLASS, std::
size_t DIM>
26 DERIVEDCLASS&
derived() {
return *
static_cast<DERIVEDCLASS*
>(
this); }
29 return *
static_cast<const DERIVEDCLASS*
>(
this);
40 template <
class OTHERCLASS>
43 const int dims = std::min(
44 size_t(DERIVEDCLASS::static_size),
45 size_t(OTHERCLASS::is3DPoseOrPoint() ? 3 : 2));
46 for (
int i = 0; i < dims; i++)
48 static_cast<const OTHERCLASS*
>(&b)->m_coords[i];
54 for (
int i = 0; i < DERIVEDCLASS::static_size; i++)
62 template <
class MATRIX44>
65 out_HM.setIdentity(4);
66 out_HM(0, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
x();
67 out_HM(1, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->
y();
68 if (DERIVEDCLASS::is3DPoseOrPoint())
69 out_HM(2, 3) =
static_cast<const DERIVEDCLASS*
>(
this)->m_coords[2];
93 return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[i];
101 template <
class DERIVEDCLASS, std::
size_t DIM>
110 return a.
y() < b.
y();
111 else if (a.
y() < b.
y())
118 template <
class DERIVEDCLASS, std::
size_t DIM>
122 for (
int i = 0; i < DERIVEDCLASS::static_size; i++)
123 if (p1[i] != p2[i])
return false;
127 template <
class DERIVEDCLASS, std::
size_t DIM>
131 for (
int i = 0; i < DERIVEDCLASS::static_size; i++)
132 if (p1[i] != p2[i])
return true;
bool operator<(const CPoint< DERIVEDCLASS, DIM > &a, const CPoint< DERIVEDCLASS, DIM > &b)
Used by STL algorithms.
double & operator[](unsigned int i)
void AddComponents(const OTHERCLASS &b)
Scalar addition of all coordinates.
const DERIVEDCLASS & derived() const
std::string asString() const
A base class for representing a point in 2D or 3D.
double x() const
Common members of all points & poses classes.
The base template class for 2D & 3D points and poses.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
static bool is3DPoseOrPoint()
Return true for poses or points with a Z component, false otherwise.
bool operator!=(const CPoint< DERIVEDCLASS, DIM > &p1, const CPoint< DERIVEDCLASS, DIM > &p2)
void getHomogeneousMatrix(MATRIX44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
bool operator==(const CPoint< DERIVEDCLASS, DIM > &p1, const CPoint< DERIVEDCLASS, DIM > &p2)
void operator*=(const double s)
Scalar multiplication.
double operator[](unsigned int i) const
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04]" ) ...