30 p.getAsQuaternion(m_quat);
52 out_HM.get_unsafe(0, 3) =
m_coords[0];
53 out_HM.get_unsafe(1, 3) =
m_coords[1];
54 out_HM.get_unsafe(2, 3) =
m_coords[2];
55 out_HM.get_unsafe(3, 0) = out_HM.get_unsafe(3, 1) =
56 out_HM.get_unsafe(3, 2) = 0;
57 out_HM.get_unsafe(3, 3) = 1;
113 const double lx,
const double ly,
const double lz,
double& gx,
double& gy,
118 if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
125 if (out_jacobian_df_dpoint)
140 1 - 2 * (qx2 + qy2)};
145 if (out_jacobian_df_dpose)
149 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
171 out_jacobian_df_dpose->insertMatrix(
188 const double gx,
const double gy,
const double gz,
double& lx,
double& ly,
193 if (out_jacobian_df_dpoint || out_jacobian_df_dpose)
200 if (out_jacobian_df_dpoint)
225 1 - 2 * (qx2 + qy2)};
230 if (out_jacobian_df_dpose)
253 2 * qy2 + 2 * qz2 - 1,
254 -2 * qr * qz - 2 * qx * qy,
255 2 * qr * qy - 2 * qx * qz,
261 2 * qr * qz - 2 * qx * qy,
262 2 * qx2 + 2 * qz2 - 1,
263 -2 * qr * qx - 2 * qy * qz,
269 -2 * qr * qy - 2 * qx * qz,
270 2 * qr * qx - 2 * qy * qz,
271 2 * qx2 + 2 * qy2 - 1,
280 const double Ax = 2 * (gx -
m_coords[0]);
281 const double Ay = 2 * (gy -
m_coords[1]);
282 const double Az = 2 * (gz -
m_coords[2]);
285 const double vals[3 * 4] = {-qy * Az + qz * Ay,
287 qx * Ay - 2 * qy * Ax - qr * Az,
288 qx * Az + qr * Ay - 2 * qz * Ax,
291 qy * Ax - 2 * qx * Ay + qr * Az,
293 qy * Az - 2 * qz * Ay - qr * Ax,
296 qz * Ax - qr * Ay - 2 * qx * Az,
297 qr * Ax + qz * Ay - 2 * qy * Az,
303 out_jacobian_df_dpose->insertMatrix(
354 const TPoint3D& point,
double& out_range,
double& out_yaw,
359 const bool comp_jacobs =
360 out_jacob_dryp_dpoint !=
nullptr || out_jacob_dryp_dpose !=
nullptr;
364 *ptr_ja1 = comp_jacobs ? &jacob_dinv_dpoint :
nullptr;
366 *ptr_ja2 = comp_jacobs ? &jacob_dinv_dpose :
nullptr;
373 out_range =
local.norm();
383 out_pitch = -asin(
local.z / out_range);
405 const double _r = 1.0 / out_range;
409 const double t2 = std::sqrt(x2 + y2);
410 const double _K = 1.0 / (t2 *
square(out_range));
412 double vals[3 * 3] = {
local.x * _r,
415 -
local.y / (x2 * (y2 / x2 + 1)),
416 1.0 / (
local.x * (y2 / x2 + 1)),
423 if (out_jacob_dryp_dpoint)
424 out_jacob_dryp_dpoint->multiply(
425 dryp_dlocalpoint, jacob_dinv_dpoint);
426 if (out_jacob_dryp_dpose)
427 out_jacob_dryp_dpose->multiply(dryp_dlocalpoint, jacob_dinv_dpose);
435 const std::streamsize old_pre = o.precision();
436 const ios_base::fmtflags old_flags = o.flags();
437 o <<
"(x,y,z,qr,qx,qy,qz)=(" << std::fixed << std::setprecision(4)
438 <<
p.m_coords[0] <<
"," <<
p.m_coords[1] <<
"," <<
p.m_coords[2] <<
"," 439 <<
p.quat()[0] <<
"," <<
p.quat()[1] <<
"," <<
p.quat()[2] <<
"," 440 <<
p.quat()[3] <<
")";
442 o.precision(old_pre);
470 for (
int i = 0; i < 3; i++)
471 m_coords[i] = std::numeric_limits<double>::quiet_NaN();
473 for (
int i = 0; i < 4; i++)
474 quat()[i] = std::numeric_limits<double>::quiet_NaN();
479 return p1.
quat() == p2.
quat() && p1.
x() == p2.
x() && p1.
y() == p2.
y() &&
491 p.inverseComposePoint(
G[0],
G[1],
G[2], L[0], L[1], L[2]);
498 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 .
#define MRPT_MAX_ALIGN_BYTES
#define THROW_EXCEPTION(msg)
#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.
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...
mrpt::math::TPose3DQuat asTPose() const
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.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
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 .
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...
bool operator!=(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
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.
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)
Lightweight 3D pose (three spatial coordinates, plus a quaternion ).
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.
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.
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.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
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
Pure virtual method for reading (deserializing) from an abstract archive.
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].