9 #ifndef mrpt_math_slerp_H 10 #define mrpt_math_slerp_H 44 q0[0] * q1[0] + q0[1] * q1[1] + q0[2] * q1[2] + q0[3] * q1[3];
46 if (std::abs(cosHalfTheta) >= 1.0)
51 bool reverse_q1 =
false;
55 cosHalfTheta = -cosHalfTheta;
58 const double halfTheta = acos(cosHalfTheta);
59 const double sinHalfTheta =
63 if (std::abs(sinHalfTheta) < 0.001)
66 for (
int i = 0; i < 4; i++)
q[i] = (1 -
t) * q0[i] +
t * q1[i];
68 for (
int i = 0; i < 4; i++)
q[i] = (1 -
t) * q0[i] -
t * q1[i];
71 const double A = sin((1 -
t) * halfTheta) / sinHalfTheta;
72 const double B = sin(
t * halfTheta) / sinHalfTheta;
74 for (
int i = 0; i < 4; i++)
q[i] = A * q0[i] + B * q1[i];
76 for (
int i = 0; i < 4; i++)
q[i] = A * q0[i] - B * q1[i];
void slerp(const CQuaternion< T > &q0, const CQuaternion< T > &q1, const double t, CQuaternion< T > &q)
SLERP interpolation between two quaternions.
GLdouble GLdouble GLdouble GLdouble q
void slerp_ypr(const mrpt::math::TPose3D &q0, const mrpt::math::TPose3D &q1, const double t, mrpt::math::TPose3D &p)
T square(const T x)
Inline function for the square of a number.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERTDEB_(f)
Defines an assertion mechanism - only when compiled in debug.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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 ...