diff options
author | 2008-09-09 15:25:03 +0000 | |
---|---|---|
committer | 2008-09-09 15:25:03 +0000 | |
commit | d3a70b7facea2919b5ee0451d3c639dedb00ea30 (patch) | |
tree | 93c8f1effe434e0070cc329fa0e322caf2f168c1 /Eigen/src/Geometry | |
parent | 703539110b5c26f01ac37fe6114afdbb5c3c6c99 (diff) |
fix a numerical instability in Quaternion::slerp
Diffstat (limited to 'Eigen/src/Geometry')
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 876524cc0..97add91d9 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -369,13 +369,14 @@ Quaternion<Scalar> Quaternion<Scalar>::slerp(Scalar t, const Quaternion& other) // 2 - Quaternion slerp(Scalar t, const Quaternion& other) const // which returns the s-lerp between this and other // ?? - if (m_coeffs == other.m_coeffs) - return *this; - + static const Scalar one = Scalar(1) - precision<Scalar>(); Scalar d = m_coeffs.dot(other.m_coeffs); + Scalar absD = ei_abs(d); + if (d>=one) + return *this; // theta is the angle between the 2 quaternions - Scalar theta = std::acos(ei_abs(d)); + Scalar theta = std::acos(absD); Scalar sinTheta = ei_sin(theta); Scalar scale0 = ei_sin( ( Scalar(1) - t ) * theta) / sinTheta; |