63 inline CPose3DQuat() : m_quat() { m_coords[0]=m_coords[1]=m_coords[2]=0.; }
92 v[0] = m_coords[0];
v[1] = m_coords[1];
v[2] = m_coords[2];
93 v[3] = m_quat[0];
v[4] = m_quat[1];
v[5] = m_quat[2];
v[6] = m_quat[3];
111 void composePoint(
const double lx,
const double ly,
const double lz,
double &gx,
double &gy,
double &gz,
118 void inverseComposePoint(
const double gx,
const double gy,
const double gz,
double &lx,
double &ly,
double &lz,
125 template <
class POINT1,
class POINT2>
inline void composePoint(
const POINT1 &L, POINT2 &G)
const {
composePoint(L[0],L[1],L[2], G[0],G[1],G[2]); }
142 composeFrom(*
this,
b);
157 inverseComposeFrom(*
this,
b);
184 if (!m.fromMatlabStringFormat(
s))
THROW_EXCEPTION(
"Malformed expression in ::fromString");
186 m_coords[0] = m.get_unsafe(0,0); m_coords[1] = m.get_unsafe(0,1); m_coords[2] = m.get_unsafe(0,2);
187 m_quat[0] = m.get_unsafe(0,3); m_quat[1] = m.get_unsafe(0,4); m_quat[2] = m.get_unsafe(0,5); m_quat[3] = m.get_unsafe(0,6);
195 case 0:
return m_coords[0];
196 case 1:
return m_coords[1];
197 case 2:
return m_coords[2];
198 case 3:
return m_quat[0];
199 case 4:
return m_quat[1];
200 case 5:
return m_quat[2];
201 case 6:
return m_quat[3];
203 throw std::runtime_error(
"CPose3DQuat::operator[]: Index of bounds.");
211 case 0:
return m_coords[0];
212 case 1:
return m_coords[1];
213 case 2:
return m_coords[2];
214 case 3:
return m_quat[0];
215 case 4:
return m_quat[1];
216 case 5:
return m_quat[2];
217 case 6:
return m_quat[3];
219 throw std::runtime_error(
"CPose3DQuat::operator[]: Index of bounds.");
227 void sphericalCoordinates(
238 enum { is_3D_val = 1 };
239 static inline bool is_3D() {
return is_3D_val!=0; }
240 enum { rotation_dimensions = 3 };
241 enum { is_PDF_val = 1 };
242 static inline bool is_PDF() {
return is_PDF_val!=0; }
258 static inline bool empty() {
return false; }
260 static inline void resize(
const size_t n) {
if (
n!=
static_size)
throw std::logic_error(
format(
"Try to change the size of CPose3DQuat to %u.",static_cast<unsigned>(
n))); }
264 if (N!=7)
throw std::runtime_error(
"CPose3DQuat::assign: Try to resize to length!=7.");
272 typedef std::iterator<std::random_access_iterator_tag,value_type>
iterator_base;
280 ASSERTMSG_(m_obj!=NULL,
"non initialized iterator");
281 if (m_cur_idx> (allow_end ? 7u : 6u) )
THROW_EXCEPTION(
"Index out of range in iterator.")
323 return (*
this)+=(-off);
339 typedef std::iterator<std::random_access_iterator_tag,value_type>
iterator_base;
347 ASSERTMSG_(m_obj!=NULL,
"non initialized iterator");
348 if (m_cur_idx> (allow_end ? 7u : 6u) )
THROW_EXCEPTION(
"Index out of range in iterator.")
390 return (*
this)+=(-off);
CPose3DQuat * m_obj
A reference to the source of this iterator.
value_type T
The type of the matrix elements.
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
const double & const_reference
static size_type max_size()
size_t m_cur_idx
The iterator points to this element.
const_iterator end() const
void normalize()
Normalize this quaternion, so its norm becomes the unitity.
CPose3DQuat(mrpt::math::TConstructorFlags_Quaternions)
Constructor which left all the quaternion members un-initialized, for use when speed is critical; Use...
void assign(const size_t N, const double val)
mrpt::math::CArrayDouble< 3 > & xyz()
Read/Write access to the translation vector in R^3.
CPose3DQuat::reference operator*() const
reverse_iterator rbegin()
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define DEFINE_SERIALIZABLE_PRE(class_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
iterator_base::difference_type operator-(const iterator &it) const
TConstructorFlags_Quaternions
bool operator!=(const const_iterator &it) const
mrpt::math::TPoint2D BASE_IMPEXP operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
iterator(CPose3DQuat &obj, size_t start_idx)
#define THROW_EXCEPTION(msg)
const_reverse_iterator rbegin() const
GLdouble GLdouble GLdouble GLdouble q
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
CPose3DQuat(const mrpt::math::TPose3DQuat &p)
Constructor from lightweight object.
std::iterator< std::random_access_iterator_tag, value_type > iterator_base
EIGEN_STRONG_INLINE iterator begin()
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
CPose3DQuat::reference operator[](iterator_base::difference_type off) const
void check_limits(bool allow_end=false) const
const mrpt::math::CArrayDouble< 3 > & xyz() const
Read-only access to the translation vector in R^3.
const Scalar * const_iterator
GLsizei GLsizei GLuint * obj
const_iterator operator++(int)
CPose3DQuat::const_reference operator*() const
iterator & operator+=(iterator_base::difference_type off)
iterator_base::difference_type operator-(const const_iterator &it) const
bool operator!=(const iterator &it) const
A numeric matrix of compile-time fixed size.
const_iterator begin() const
void getAsVector(mrpt::math::CArrayDouble< 7 > &v) const
const_iterator & operator-=(iterator_base::difference_type off)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void composeFrom(const CPose3DQuat &A, const CPose3DQuat &B)
Makes this method is slightly more efficient than "this= A + B;" since it avoids the temporary objec...
const_iterator operator+(iterator_base::difference_type off) const
const mrpt::math::CQuaternionDouble & quat() const
Read-only access to the quaternion representing the 3D rotation.
std::vector< T1 > & operator+=(std::vector< T1 > &a, const std::vector< T2 > &b)
a+=b (element-wise sum)
CPose2D BASE_IMPEXP operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
const_iterator operator-(iterator_base::difference_type off) const
const CPose3DQuat * m_obj
A reference to the source of this iterator.
A base class for representing a pose in 2D or 3D.
const type_value & getPoseMean() const
Eigen::Matrix< dataType, 4, 4 > inverse(Eigen::Matrix< dataType, 4, 4 > &pose)
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
double value_type
The type of the elements.
bool operator==(const iterator &it) const
double & operator[](unsigned int i)
Read/write [] operator.
bool operator>(const CArray< T, N > &x, const CArray< T, N > &y)
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
iterator operator-(iterator_base::difference_type off) const
GLsizei const GLchar ** string
A class used to store a 3D point.
type_value & getPoseMean()
const_iterator operator--(int)
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].
void inverseComposePoint(const POINT1 &G, POINT2 &L) const
Computes the 3D point L such as .
const_iterator & operator++()
CPose3DQuat(TConstructorFlags_Poses)
void composePoint(const POINT1 &L, POINT2 &G) const
Computes the 3D point G such as .
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
size_t size(const MATRIXLIKE &m, const int dim)
CPose3DQuat mrpt_autotype
See ops_containers.h.
static void resize(const size_t n)
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
CPose3DQuat(const double x, const double y, const double z, const mrpt::math::CQuaternionDouble &q)
Constructor with initilization of the pose - the quaternion is normalized to make sure it's unitary...
std::iterator< std::random_access_iterator_tag, value_type > iterator_base
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
std::ptrdiff_t difference_type
iterator operator+(iterator_base::difference_type off) const
iterator & operator-=(iterator_base::difference_type off)
const_reverse_iterator rend() const
const_iterator & operator+=(iterator_base::difference_type off)
void asString(std::string &s) const
Returns a human-readable textual representation of the object (eg: "[x y z qr qx qy qz]"...
CPose3DQuat()
Default constructor, initialize translation to zeros and quaternion to no rotation.
void inverseComposeFrom(const CPose3DQuat &A, const CPose3DQuat &B)
Makes this method is slightly more efficient than "this= A - B;" since it avoids the temporary objec...
bool operator<(const CPoint< DERIVEDCLASS > &a, const CPoint< DERIVEDCLASS > &b)
Used by STL algorithms.
void check_limits(bool allow_end=false) const
bool operator==(const const_iterator &it) const
#define DEFINE_SERIALIZABLE_POST(class_name)
mrpt::math::CQuaternionDouble m_quat
The quaternion.
std::reverse_iterator< iterator > reverse_iterator
const double & operator[](unsigned int i) const
Read only [] operator.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
CPose3DQuat type_value
Used to emulate CPosePDF types, for example, in mrpt::graphs::CNetworkOfPoses.
std::reverse_iterator< const_iterator > const_reverse_iterator
size_t m_cur_idx
The iterator points to this element.
value_type T
The type of the matrix elements.
#define ASSERTMSG_(f, __ERROR_MSG)
const_iterator & operator--()
const_iterator(const CPose3DQuat &obj, size_t start_idx)
std::vector< T1 > & operator*=(std::vector< T1 > &a, const std::vector< T2 > &b)
a*=b (element-wise multiplication)
std::string asString() const
CPose3DQuat::const_reference operator[](iterator_base::difference_type off) const
void swap(CPose3DQuat &o)