31 p.getAsQuaternion(m_quat);
53 out_HM.get_unsafe(0, 3) =
m_coords[0];
54 out_HM.get_unsafe(1, 3) =
m_coords[1];
55 out_HM.get_unsafe(2, 3) =
m_coords[2];
56 out_HM.get_unsafe(3, 0) = out_HM.get_unsafe(3, 1) =
57 out_HM.get_unsafe(3, 2) = 0;
58 out_HM.get_unsafe(3, 3) = 1;
114 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(16)
const double vals[3 * 3] = {
141 1 - 2 * (qx2 + qy2)};
146 if (out_jacobian_df_dpose)
149 alignas(16)
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(16)
const double vals[3 * 4] = {
172 out_jacobian_df_dpose->insertMatrix(
189 const double gx,
const double gy,
const double gz,
double& lx,
double& ly,
194 if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
201 if (out_jacobian_df_dpoint)
215 alignas(16)
const double vals[3 * 3] = {
226 1 - 2 * (qx2 + qy2)};
231 if (out_jacobian_df_dpose)
253 alignas(16)
const double vals1[3 * 7] = {
254 2 * qy2 + 2 * qz2 - 1,
255 -2 * qr * qz - 2 * qx * qy,
256 2 * qr * qy - 2 * qx * qz,
262 2 * qr * qz - 2 * qx * qy,
263 2 * qx2 + 2 * qz2 - 1,
264 -2 * qr * qx - 2 * qy * qz,
270 -2 * qr * qy - 2 * qx * qz,
271 2 * qr * qx - 2 * qy * qz,
272 2 * qx2 + 2 * qy2 - 1,
281 const double Ax = 2 * (gx -
m_coords[0]);
282 const double Ay = 2 * (gy -
m_coords[1]);
283 const double Az = 2 * (gz -
m_coords[2]);
286 const double vals[3 * 4] = {-qy * Az + qz * Ay,
288 qx * Ay - 2 * qy * Ax - qr * Az,
289 qx * Az + qr * Ay - 2 * qz * Ax,
292 qy * Ax - 2 * qx * Ay + qr * Az,
294 qy * Az - 2 * qz * Ay - qr * Ax,
297 qz * Ax - qr * Ay - 2 * qx * Az,
298 qr * Ax + qz * Ay - 2 * qy * Az,
304 out_jacobian_df_dpose->insertMatrix(
367 const TPoint3D& point,
double& out_range,
double& out_yaw,
372 const bool comp_jacobs =
373 out_jacob_dryp_dpoint !=
nullptr || out_jacob_dryp_dpose !=
nullptr;
377 *ptr_ja1 = comp_jacobs ? &jacob_dinv_dpoint :
nullptr;
379 *ptr_ja2 = comp_jacobs ? &jacob_dinv_dpose :
nullptr;
386 out_range =
local.norm();
396 out_pitch = -asin(
local.z / out_range);
418 const double _r = 1.0 / out_range;
422 const double t2 = std::sqrt(x2 + y2);
423 const double _K = 1.0 / (t2 *
square(out_range));
425 double vals[3 * 3] = {
local.x * _r,
428 -
local.y / (x2 * (y2 / x2 + 1)),
429 1.0 / (
local.x * (y2 / x2 + 1)),
436 if (out_jacob_dryp_dpoint)
437 out_jacob_dryp_dpoint->multiply(
438 dryp_dlocalpoint, jacob_dinv_dpoint);
439 if (out_jacob_dryp_dpose)
440 out_jacob_dryp_dpose->multiply(dryp_dlocalpoint, jacob_dinv_dpose);
448 const std::streamsize old_pre = o.precision();
449 const ios_base::fmtflags old_flags = o.flags();
450 o <<
"(x,y,z,qr,qx,qy,qz)=(" << std::fixed << std::setprecision(4)
451 <<
p.m_coords[0] <<
"," <<
p.m_coords[1] <<
"," <<
p.m_coords[2] <<
"," 452 <<
p.quat()[0] <<
"," <<
p.quat()[1] <<
"," <<
p.quat()[2] <<
"," 453 <<
p.quat()[3] <<
")";
455 o.precision(old_pre);
483 for (
int i = 0; i < 3; i++)
484 m_coords[i] = std::numeric_limits<double>::quiet_NaN();
486 for (
int i = 0; i < 4; i++)
487 quat()[i] = std::numeric_limits<double>::quiet_NaN();
492 return p1.
quat() == p2.
quat() && p1.
x() == p2.
x() && p1.
y() == p2.
y() &&
504 p.inverseComposePoint(G[0], G[1], G[2], L[0], L[1], L[2]);
512 p.inverseComposePoint(G[0], G[1], G[2], L[0], L[1], L[2]);
void getAsVector(mrpt::math::CVectorDouble &v) const
Returns a 1x7 vector with [x y z qr qx qy qz].
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.
double x() const
Common members of all points & poses classes.
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point L such as .
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
T y() const
Return y coordinate of the quaternion.
#define THROW_EXCEPTION(msg)
void rotationMatrixNoResize(MATRIXLIKE &M) const
Fill out the top-left 3x3 block of the given matrix with the rotation matrix associated to this quate...
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacob_dryp_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< 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.
T square(const T x)
Inline function for the square of a number.
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point G such as .
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
T r() const
Return r coordinate of the quaternion.
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...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
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.
double x
X,Y,Z coordinates.
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.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
virtual void operator*=(const double s)
Scalar multiplication (all x y z qr qx qy qz elements are multiplied by the scalar).
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void loadFromArray(const T *vals)
mrpt::math::CArrayDouble< 3 > m_coords
The translation vector [x,y,z].
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
T x() const
Return x coordinate of the quaternion.
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void getHomogeneousMatrix(mrpt::math::CMatrixDouble44 &out_HM) const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
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.
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.
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].