28 #ifndef CPOSE3DROTVEC_H
29 #define CPOSE3DROTVEC_H
39 using namespace mrpt::math;
77 inline CPose3DRotVec() {
78 m_coords[0]=m_coords[1]=m_coords[2]=0;
79 m_rotvec[0]=m_rotvec[1]=m_rotvec[2]=0;
86 inline CPose3DRotVec(
const double x,
const double y,
const double z,
const double vx,
const double vy,
const double vz) {
87 m_coords[0]= x; m_coords[1]= y; m_coords[2]= z;
88 m_rotvec[0]=vx; m_rotvec[1]=vy; m_rotvec[2]=vz;
93 m_coords[0]=v[0]; m_coords[1]=v[1]; m_coords[2]=v[2];
94 m_rotvec[0]=v[3]; m_rotvec[1]=v[4]; m_rotvec[2]=v[5];
101 explicit CPose3DRotVec(
const CPose3D &);
111 m_coords[0]=vec6[0]; m_coords[1]=vec6[1]; m_coords[2]=vec6[2];
112 m_rotvec[0]=vec6[3]; m_rotvec[1]=vec6[4]; m_rotvec[2]=vec6[5];
125 out_HM.block<3,3>(0,0) = getRotationMatrix();
126 out_HM.get_unsafe(0,3)=m_coords[0];
127 out_HM.get_unsafe(1,3)=m_coords[1];
128 out_HM.get_unsafe(2,3)=m_coords[2];
129 out_HM.get_unsafe(3,0)=0; out_HM.get_unsafe(3,1)=0; out_HM.get_unsafe(3,2)=0; out_HM.get_unsafe(3,3)=1;
146 inline CPose3DRotVec
operator + (
const CPose3DRotVec& b)
const
160 void sphericalCoordinates(
164 double &out_pitch )
const;
170 void composePoint(
double lx,
double ly,
double lz,
double &gx,
double &gy,
double &gz,
178 composePoint(local_point.
x,local_point.
y,local_point.
z, global_point.
x,global_point.
y,global_point.
z );
186 void inverseComposePoint(
const double gx,
const double gy,
const double gz,
double &lx,
double &ly,
double &lz,
193 void composeFrom(
const CPose3DRotVec& A,
const CPose3DRotVec& B );
198 composeFrom(*
this,b);
206 void inverseComposeFrom(
const CPose3DRotVec& A,
const CPose3DRotVec& B );
209 inline CPose3DRotVec
operator - (
const CPose3DRotVec& b)
const
228 inline double rx()
const {
return m_rotvec[0]; }
229 inline double ry()
const {
return m_rotvec[1]; }
230 inline double rz()
const {
return m_rotvec[2]; }
232 inline double &
rx() {
return m_rotvec[0]; }
233 inline double &
ry() {
return m_rotvec[1]; }
234 inline double &
rz() {
return m_rotvec[2]; }
259 m_coords[0]=x0; m_coords[1]=y0; m_coords[2]=z0;
260 m_rotvec[0]=vx; m_rotvec[1]=vy; m_rotvec[2]=vz;
267 template <
class ARRAYORVECTOR>
268 inline void setFrom6Vector(
const ARRAYORVECTOR &vec6)
270 m_rotvec[0]=vec6[3]; m_rotvec[1]=vec6[4]; m_rotvec[2]=vec6[5];
271 m_coords[0]=vec6[0]; m_coords[1]=vec6[1]; m_coords[2]=vec6[2];
279 template <
class ARRAYORVECTOR>
280 inline void getAs6Vector(ARRAYORVECTOR &vec6)
const
282 vec6[0]=m_coords[0]; vec6[1]=m_coords[1]; vec6[2]=m_coords[2];
283 vec6[3]=m_rotvec[0]; vec6[4]=m_rotvec[1]; vec6[5]=m_rotvec[2];
287 template <
class ARRAYORVECTOR>
288 inline void getAsVector(ARRAYORVECTOR &v)
const { v.resize(6); getAs6Vector(v); }
290 inline const double &operator[](
unsigned int i)
const
294 case 0:
return m_coords[0];
295 case 1:
return m_coords[1];
296 case 2:
return m_coords[2];
297 case 3:
return m_rotvec[0];
298 case 4:
return m_rotvec[1];
299 case 5:
return m_rotvec[2];
301 throw std::runtime_error(
"CPose3DRotVec::operator[]: Index of bounds.");
304 inline double &operator[](
unsigned int i)
308 case 0:
return m_coords[0];
309 case 1:
return m_coords[1];
310 case 2:
return m_coords[2];
311 case 3:
return m_rotvec[0];
312 case 4:
return m_rotvec[1];
313 case 5:
return m_rotvec[2];
315 throw std::runtime_error(
"CPose3DRotVec::operator[]: Index of bounds.");
322 void asString(std::string &s)
const { s =
mrpt::format(
"[%f %f %f %f %f %f]",m_coords[0],m_coords[1],m_coords[2],m_rotvec[0],m_rotvec[1],m_rotvec[2]); }
331 if (!m.fromMatlabStringFormat(s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
333 for (
int i=0;i<3;i++) m_coords[i]=m.get_unsafe(0,i);
334 for (
int i=0;i<3;i++) m_rotvec[i]=m.get_unsafe(0,3+i);
355 enum { is_3D_val = 1 };
356 static inline bool is_3D() {
return is_3D_val!=0; }
357 enum { rotation_dimensions = 3 };
358 enum { is_PDF_val = 0 };
359 static inline bool is_PDF() {
return is_PDF_val!=0; }
376 static inline bool empty() {
return false; }
378 static inline void resize(
const size_t n) {
if (n!=
static_size)
throw std::logic_error(
format(
"Try to change the size of CPose3DRotVec to %u.",static_cast<unsigned>(n))); }