aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Geometry/Quaternion.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-03-04 17:03:13 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-03-04 17:03:13 +0100
commit2dc968e453e347966b7a45c9c497c6b1d3845f80 (patch)
tree0190e7367e3d4954948a4fedb8fb9ba47fba9576 /Eigen/src/Geometry/Quaternion.h
parent2231b3dece9260ee0ba84e9080f11d2015ed5d90 (diff)
bug #824: improve accuracy of Quaternion::angularDistance using atan2 instead of acos.
Diffstat (limited to 'Eigen/src/Geometry/Quaternion.h')
-rw-r--r--Eigen/src/Geometry/Quaternion.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h
index 8c44df699..e90ce77eb 100644
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -680,12 +680,10 @@ template <class OtherDerived>
inline typename internal::traits<Derived>::Scalar
QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
{
- using std::acos;
+ using std::atan2;
using std::abs;
- Scalar d = abs(this->dot(other));
- if (d>=Scalar(1))
- return Scalar(0);
- return Scalar(2) * acos(d);
+ Quaternion<Scalar> d = (*this) * other.conjugate();
+ return Scalar(2) * atan2( d.vec().norm(), abs(d.w()) );
}