Main MRPT website > C++ reference for MRPT 1.9.9
slerp.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/slerp.h>
13 #include <mrpt/poses/CPose3D.h>
14 #include <mrpt/poses/CPose3DQuat.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::poses;
18 using namespace mrpt::math;
19 
21  const CPose3D& p0, const CPose3D& p1, const double t, CPose3D& p)
22 {
23  CQuaternionDouble q0, q1, q;
24  p0.getAsQuaternion(q0);
25  p1.getAsQuaternion(q1);
26  // The quaternion part (this will raise exception on t not in [0,1])
27  mrpt::math::slerp(q0, q1, t, q);
28  // XYZ:
29  p = CPose3D(
30  q, (1 - t) * p0.x() + t * p1.x(), (1 - t) * p0.y() + t * p1.y(),
31  (1 - t) * p0.z() + t * p1.z());
32 }
33 
35  const CPose3DQuat& q0, const CPose3DQuat& q1, const double t,
36  CPose3DQuat& q)
37 {
38  // The quaternion part (this will raise exception on t not in [0,1])
39  mrpt::math::slerp(q0.quat(), q1.quat(), t, q.quat());
40  // XYZ:
41  q.x((1 - t) * q0.x() + t * q1.x());
42  q.y((1 - t) * q0.y() + t * q1.y());
43  q.z((1 - t) * q0.z() + t * q1.z());
44 }
45 
47  const mrpt::math::TPose3D& q0, const mrpt::math::TPose3D& q1,
48  const double t, mrpt::math::TPose3D& p)
49 {
52  q0.getAsQuaternion(quat0);
53  q1.getAsQuaternion(quat1);
54  mrpt::math::slerp(quat0, quat1, t, q);
55 
56  p.x = p.y = p.z = 0;
57  q.rpy(p.roll, p.pitch, p.yaw);
58 }
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
Definition: CPose3DQuat.h:60
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
GLdouble GLdouble t
Definition: glext.h:3689
void slerp(const CQuaternion< T > &q0, const CQuaternion< T > &q1, const double t, CQuaternion< T > &q)
SLERP interpolation between two quaternions.
Definition: slerp.h:35
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
void getAsQuaternion(mrpt::math::CQuaternion< double > &q, mrpt::math::CMatrixFixedNumeric< double, 4, 3 > *out_dq_dr=NULL) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored) ...
void getAsQuaternion(mrpt::math::CQuaternionDouble &q, mrpt::math::CMatrixFixedNumeric< double, 4, 3 > *out_dq_dr=nullptr) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored) ...
Definition: CPose3D.cpp:584
void slerp_ypr(const mrpt::math::TPose3D &q0, const mrpt::math::TPose3D &q1, const double t, mrpt::math::TPose3D &p)
Definition: slerp.cpp:46
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:48
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:46
GLfloat GLfloat p
Definition: glext.h:6305



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019