28 #ifndef CPOSEORPOINT_H
29 #define CPOSEORPOINT_H
51 using namespace mrpt::utils;
52 using namespace mrpt::math;
128 template <
class DERIVEDCLASS>
129 class CPoseOrPoint :
public mrpt::poses::detail::pose_point_impl<DERIVEDCLASS, mrpt::poses::detail::T3DTypeHelper<DERIVEDCLASS>::is_3D_val>
135 inline double x() const {
return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[0]; }
136 inline double y() const {
return static_cast<const DERIVEDCLASS*
>(
this)->m_coords[1]; }
138 inline double &
x() {
return static_cast<DERIVEDCLASS*
>(
this)->m_coords[0]; }
139 inline double &
y() {
return static_cast<DERIVEDCLASS*
>(
this)->m_coords[1]; }
141 inline void x(
const double v) {
static_cast<DERIVEDCLASS*
>(
this)->m_coords[0]=v; }
142 inline void y(
const double v) {
static_cast<DERIVEDCLASS*
>(
this)->m_coords[1]=v; }
144 inline void x_incr(
const double v) {
static_cast<DERIVEDCLASS*
>(
this)->m_coords[0]+=v; }
145 inline void y_incr(
const double v) {
static_cast<DERIVEDCLASS*
>(
this)->m_coords[1]+=v; }
156 if (is3DPoseOrPoint())
157 return square(x()-b.
x()) +
square(y()-b.
y()) +
square(static_cast<const DERIVEDCLASS*>(
this)->m_coords[2]-
static_cast<const OTHERCLASS*
>(&b)->m_coords[2]);
158 else return square(x()-b.
x()) +
square(y()-b.
y()) +
square(static_cast<const OTHERCLASS*>(&b)->m_coords[2]);
162 if (is3DPoseOrPoint())
163 return square(x()-b.
x()) +
square(y()-b.
y()) +
square(static_cast<const OTHERCLASS*>(&b)->m_coords[2]);
169 template <
class OTHERCLASS>
172 return std::sqrt( sqrDistanceTo(b));
180 return square(ax-x())+
square(ay-y())+
square(az-(is3DPoseOrPoint() ? static_cast<const DERIVEDCLASS*>(
this)->m_coords[2] : 0) );
184 inline double distance2DTo(
double ax,
double ay )
const {
return std::sqrt(distance2DToSquare(ax,ay)); }
187 inline double distance3DTo(
double ax,
double ay,
double az )
const {
return std::sqrt(distance3DToSquare(ax,ay,az)); }
195 return std::sqrt(
square(x())+
square(y())+ (!is3DPoseOrPoint() ? 0 :
square(static_cast<const DERIVEDCLASS*>(
this)->m_coords[2]) ) );
202 static_cast<const DERIVEDCLASS*
>(
this)->getAsVector(v);
212 static_cast<const DERIVEDCLASS*
>(
this)->getHomogeneousMatrix(m);
221 static_cast<const DERIVEDCLASS*
>(
this)->getHomogeneousMatrix(out_HM);
229 getInverseHomogeneousMatrix(M);