17 #include <Eigen/Dense>    34     p.getAsQuaternion(m_quat);
    59     out_HM(3, 0) = out_HM(3, 1) = out_HM(3, 2) = 0;
   105         A.m_coords[2] - B.
m_coords[2], this->m_coords[0], this->m_coords[1],
   115     const double lx, 
const double ly, 
const double lz, 
double& gx, 
double& gy,
   119     if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
   126         if (out_jacobian_df_dpoint)
   130             alignas(MRPT_MAX_STATIC_ALIGN_BYTES) 
const double vals[3 * 3] = {
   141                 1 - 2 * (qx2 + qy2)};
   146         if (out_jacobian_df_dpose)
   149             alignas(MRPT_MAX_STATIC_ALIGN_BYTES) 
const double vals1[3 * 7] = {
   150                 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
   153             alignas(MRPT_MAX_STATIC_ALIGN_BYTES) 
const double vals[3 * 4] = {
   172             out_jacobian_df_dpose->
asEigen().block<3, 4>(0, 3) =
   188     const double gx, 
const double gy, 
const double gz, 
double& lx, 
double& ly,
   192     if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
   199         if (out_jacobian_df_dpoint)
   213             alignas(MRPT_MAX_STATIC_ALIGN_BYTES) 
const double vals[3 * 3] = {
   224                 1 - 2 * (qx2 + qy2)};
   229         if (out_jacobian_df_dpose)
   251             alignas(MRPT_MAX_STATIC_ALIGN_BYTES) 
const double vals1[3 * 7] = {
   252                 2 * qy2 + 2 * qz2 - 1,
   253                 -2 * qr * qz - 2 * qx * qy,
   254                 2 * qr * qy - 2 * qx * qz,
   260                 2 * qr * qz - 2 * qx * qy,
   261                 2 * qx2 + 2 * qz2 - 1,
   262                 -2 * qr * qx - 2 * qy * qz,
   268                 -2 * qr * qy - 2 * qx * qz,
   269                 2 * qr * qx - 2 * qy * qz,
   270                 2 * qx2 + 2 * qy2 - 1,
   279             const double Ax = 2 * (gx - 
m_coords[0]);
   280             const double Ay = 2 * (gy - 
m_coords[1]);
   281             const double Az = 2 * (gz - 
m_coords[2]);
   283             alignas(MRPT_MAX_STATIC_ALIGN_BYTES)
   284                 const double vals[3 * 4] = {-qy * Az + qz * Ay,
   286                                             qx * Ay - 2 * qy * Ax - qr * Az,
   287                                             qx * Az + qr * Ay - 2 * qz * Ax,
   290                                             qy * Ax - 2 * qx * Ay + qr * Az,
   292                                             qy * Az - 2 * qz * Ay - qr * Ax,
   295                                             qz * Ax - qr * Ay - 2 * qx * Az,
   296                                             qr * Ax + qz * Ay - 2 * qy * Az,
   353     out[
"point"] = point;
   369             in[
"point"].
readTo(point);
   373             m_quat[0] = 
static_cast<double>(in[
"orientation"][
"r"]);
   374             m_quat[1] = 
static_cast<double>(in[
"orientation"][
"x"]);
   375             m_quat[2] = 
static_cast<double>(in[
"orientation"][
"y"]);
   376             m_quat[3] = 
static_cast<double>(in[
"orientation"][
"z"]);
   387     const TPoint3D& point, 
double& out_range, 
double& out_yaw,
   392     const bool comp_jacobs =
   393         out_jacob_dryp_dpoint != 
nullptr || out_jacob_dryp_dpose != 
nullptr;
   397         *ptr_ja1 = comp_jacobs ? &jacob_dinv_dpoint : 
nullptr;
   399         *ptr_ja2 = comp_jacobs ? &jacob_dinv_dpose : 
nullptr;
   403         point.
x, point.
y, point.
z, local.
x, local.
y, local.
z, ptr_ja1, ptr_ja2);
   406     out_range = local.
norm();
   409     if (local.
y != 0 || local.
x != 0)
   410         out_yaw = atan2(local.
y, local.
x);
   416         out_pitch = -asin(local.
z / out_range);
   438         const double _r = 1.0 / out_range;
   439         const double x2 = 
square(local.
x);
   440         const double y2 = 
square(local.
y);
   442         const double t2 = std::sqrt(x2 + y2);
   443         const double _K = 1.0 / (t2 * 
square(out_range));
   445         double vals[3 * 3] = {local.
x * _r,
   448                               -local.
y / (x2 * (y2 / x2 + 1)),
   449                               1.0 / (local.
x * (y2 / x2 + 1)),
   451                               (local.
x * local.
z) * _K,
   452                               (local.
y * local.
z) * _K,
   456         if (out_jacob_dryp_dpoint)
   457             *out_jacob_dryp_dpoint = dryp_dlocalpoint * jacob_dinv_dpoint;
   458         if (out_jacob_dryp_dpose)
   459             *out_jacob_dryp_dpose = dryp_dlocalpoint * jacob_dinv_dpose;
   467     const std::streamsize old_pre = o.precision();
   468     const ios_base::fmtflags old_flags = o.flags();
   469     o << 
"(x,y,z,qr,qx,qy,qz)=(" << std::fixed << std::setprecision(4)
   471       << p.
quat()[0] << 
"," << p.
quat()[1] << 
"," << p.
quat()[2] << 
","   472       << p.
quat()[3] << 
")";
   474     o.precision(old_pre);
   502     for (
int i = 0; i < 3; i++)
   503         m_coords[i] = std::numeric_limits<double>::quiet_NaN();
   505     for (
int i = 0; i < 4; i++)
   506         quat()[i] = std::numeric_limits<double>::quiet_NaN();
   511     return p1.
quat() == p2.
quat() && p1.
x() == p2.
x() && p1.
y() == p2.
y() &&
 void inverseRotatePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz) const
Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by the inverse (conjugate) of this quaternion...
 
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation. 
 
A compile-time fixed-size numeric matrix container. 
 
void fromString(const std::string &s)
Set the current object value from a string generated by 'asString' (eg: "[0.02 1.04 -0...
 
void asVector(vector_t &v) const
Returns a 7x1 vector with [x y z qr qx qy qz]'. 
 
#define THROW_EXCEPTION(msg)
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files. 
 
T y() const
Return y coordinate of the quaternion. 
 
std::ostream & operator<<(std::ostream &o, const CPoint2D &p)
Dumps a point as a string (x,y) 
 
void rotationMatrixNoResize(MATRIXLIKE &M) const
Fill out the top-left 3x3 block of the given matrix with the rotation matrix associated to this quate...
 
void insertMatrix(const int row_start, const int col_start, const OTHERMATVEC &submat)
Copies the given input submatrix/vector into this matrix/vector, starting at the given top-left coord...
 
mrpt::math::TPose3DQuat asTPose() const
 
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacob_dryp_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacob_dryp_dpose=nullptr) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
 
void setToNaN() override
Set all data fields to quiet NaN. 
 
void fromStringRaw(const std::string &s)
Same as fromString, but without requiring the square brackets in the string. 
 
void getAsQuaternion(mrpt::math::CQuaternionDouble &q, mrpt::optional_ref< mrpt::math::CMatrixDouble43 > out_dq_dr=std::nullopt) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored)  ...
 
Virtual base class for "schematic archives" (JSON, XML,...) 
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations. 
 
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point G such as . 
 
void loadFromArray(const VECTOR &vals)
 
This base provides a set of functions for maths stuff. 
 
T r() const
Return r (real part) coordinate of the quaternion. 
 
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point L such as . 
 
void crossProduct(const CQuaternion &q1, const CQuaternion &q2)
Calculate the "cross" product (or "composed rotation") of two quaternion: this = q1 x q2 After the op...
 
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...
 
void serializeTo(mrpt::serialization::CArchive &out) const override
Serialize CSerializable Object to CSchemeArchiveBase derived object. 
 
CPose2D operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
 
void inverse()
Convert this pose into its inverse, saving the result in itself. 
 
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism. 
 
bool fromMatlabStringFormat(const std::string &s, mrpt::optional_ref< std::ostream > dump_errors_here=std::nullopt)
Reads a matrix from a string in Matlab-like format, for example: "[1 0 2; 0 4 -1]" The string must st...
 
double x() const
Common members of all points & poses classes. 
 
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz). 
 
void rotatePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz) const
Rotate a 3D point (lx,ly,lz) -> (gx,gy,gz) as described by this quaternion. 
 
virtual void operator*=(const double s)
Scalar multiplication (all x y z qr qx qy qz elements are multiplied by the scalar). 
 
size_type rows() const
Number of rows in the matrix. 
 
A class used to store a 3D point. 
 
size_type cols() const
Number of columns in the matrix. 
 
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
 
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods. 
 
Lightweight 3D pose (three spatial coordinates, plus a quaternion ). 
 
bool operator!=(const CPoint< DERIVEDCLASS, DIM > &p1, const CPoint< DERIVEDCLASS, DIM > &p2)
 
return_t square(const num_t x)
Inline function for the square of a number. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
bool operator==(const CPoint< DERIVEDCLASS, DIM > &p1, const CPoint< DERIVEDCLASS, DIM > &p2)
 
T x() const
Return x coordinate of the quaternion. 
 
Virtual base class for "archives": classes abstracting I/O streams. 
 
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion. 
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
mrpt::vision::TStereoCalibResults out
 
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
 
void readTo(CSerializable &obj)
 
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object. 
 
mrpt::math::CVectorFixedDouble< 3 > m_coords
The translation vector [x,y,z]. 
 
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...
 
mrpt::math::CQuaternionDouble m_quat
The quaternion. 
 
T norm() const
Point norm: |v| = sqrt(x^2+y^2+z^2) 
 
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object. 
 
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods. 
 
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
 
T z() const
Return z coordinate of the quaternion. 
 
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Serialize CSchemeArchiveBase derived object to CSerializable Object.