39 using namespace mrpt::math;
98 mutable
bool m_ypr_uptodate;
99 mutable
double m_yaw, m_pitch, m_roll;
102 void rebuildRotationMatrix();
105 inline
void updateYawPitchRoll()
const {
if (!m_ypr_uptodate) { m_ypr_uptodate=
true; getYawPitchRoll( m_yaw, m_pitch, m_roll ); } }
115 CPose3D(
const double x,
const double y,
const double z,
const double yaw=0,
const double pitch=0,
const double roll=0);
124 template <
class MATRIX33,
class VECTOR3>
128 for (
int r=0;r<3;r++)
129 for (
int c=0;c<3;c++)
130 m_ROT(r,c)=rot.get_unsafe(r,c);
131 for (
int r=0;r<3;r++) m_coords[r]=xyz[r];
163 setFrom12Vector(vec12);
178 out_HM.insertMatrix(0,0,m_ROT);
179 for (
int i=0;i<3;i++) out_HM(i,3)=m_coords[i];
180 out_HM(3,0)=out_HM(3,1)=out_HM(3,2)=0.; out_HM(3,3)=1.;
214 void sphericalCoordinates(
218 double &out_pitch )
const;
226 void composePoint(
double lx,
double ly,
double lz,
double &gx,
double &gy,
double &gz,
230 bool use_small_rot_approx =
false)
const;
236 composePoint(local_point.
x,local_point.
y,local_point.
z, global_point.
x,global_point.
y,global_point.
z );
240 inline void composePoint(
double lx,
double ly,
double lz,
float &gx,
float &gy,
float &gz )
const {
242 composePoint(lx,ly,lz,ggx,ggy,ggz);
243 gx = ggx; gy = ggy; gz = ggz;
252 void inverseComposePoint(
const double gx,
const double gy,
const double gz,
double &lx,
double &ly,
double &lz,
260 void composeFrom(
const CPose3D& A,
const CPose3D& B );
265 composeFrom(*
this,b);
273 void inverseComposeFrom(
const CPose3D& A,
const CPose3D& B );
298 void addComponents(
const CPose3D &p);
303 void normalizeAngles();
316 const double pitch=0,
317 const double roll=0);
322 template <
typename VECTORLIKE>
323 inline void setFromXYZQ(
325 const size_t index_offset = 0)
330 q.rotationMatrixNoResize(m_ROT);
331 m_ypr_uptodate=
false;
332 m_coords[0] = v[index_offset+0];
333 m_coords[1] = v[index_offset+1];
334 m_coords[2] = v[index_offset+2];
340 inline void setYawPitchRoll(
345 setFromValues(x(),y(),z(),yaw_,pitch_,roll_);
352 template <
class ARRAYORVECTOR>
353 inline void setFrom12Vector(
const ARRAYORVECTOR &vec12)
355 m_ROT.set_unsafe(0,0, vec12[0]); m_ROT.set_unsafe(0,1, vec12[3]); m_ROT.set_unsafe(0,2, vec12[6]);
356 m_ROT.set_unsafe(1,0, vec12[1]); m_ROT.set_unsafe(1,1, vec12[4]); m_ROT.set_unsafe(1,2, vec12[7]);
357 m_ROT.set_unsafe(2,0, vec12[2]); m_ROT.set_unsafe(2,1, vec12[5]); m_ROT.set_unsafe(2,2, vec12[8]);
358 m_ypr_uptodate =
false;
359 m_coords[0] = vec12[ 9];
360 m_coords[1] = vec12[10];
361 m_coords[2] = vec12[11];
368 template <
class ARRAYORVECTOR>
369 inline void getAs12Vector(ARRAYORVECTOR &vec12)
const
371 vec12[0] = m_ROT.get_unsafe(0,0); vec12[3] = m_ROT.get_unsafe(0,1); vec12[6] = m_ROT.get_unsafe(0,2);
372 vec12[1] = m_ROT.get_unsafe(1,0); vec12[4] = m_ROT.get_unsafe(1,1); vec12[7] = m_ROT.get_unsafe(1,2);
373 vec12[2] = m_ROT.get_unsafe(2,0); vec12[5] = m_ROT.get_unsafe(2,1); vec12[8] = m_ROT.get_unsafe(2,2);
374 vec12[ 9] = m_coords[0];
375 vec12[10] = m_coords[1];
376 vec12[11] = m_coords[2];
382 void getYawPitchRoll(
double &yaw,
double &pitch,
double &roll )
const;
384 inline double yaw()
const { updateYawPitchRoll();
return m_yaw; }
385 inline double pitch()
const { updateYawPitchRoll();
return m_pitch; }
386 inline double roll()
const { updateYawPitchRoll();
return m_roll; }
398 void getAsQuaternion(
403 inline const double &operator[](
unsigned int i)
const
405 updateYawPitchRoll();
408 case 0:
return m_coords[0];
409 case 1:
return m_coords[1];
410 case 2:
return m_coords[2];
412 case 4:
return m_pitch;
413 case 5:
return m_roll;
415 throw std::runtime_error(
"CPose3D::operator[]: Index of bounds.");
434 if (!m.fromMatlabStringFormat(s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
436 this->setFromValues(m.get_unsafe(0,0),m.get_unsafe(0,1),m.get_unsafe(0,2),
DEG2RAD(m.get_unsafe(0,3)),
DEG2RAD(m.get_unsafe(0,4)),
DEG2RAD(m.get_unsafe(0,5)));
440 bool isHorizontal(
const double tolerance=0)
const;
443 double distanceEuclidean6D(
const CPose3D &o )
const;
488 enum { is_3D_val = 1 };
489 static inline bool is_3D() {
return is_3D_val!=0; }
490 enum { rotation_dimensions = 3 };
491 enum { is_PDF_val = 0 };
492 static inline bool is_PDF() {
return is_PDF_val!=0; }
509 static inline bool empty() {
return false; }
511 static inline void resize(
const size_t n) {
if (n!=
static_size)
throw std::logic_error(
format(
"Try to change the size of CPose3D to %u.",static_cast<unsigned>(n))); }
533 static_cast<const DERIVEDCLASS*
>(
this)->getHomogeneousMatrix(HM);
535 RES.multiply(B_INV,HM);