diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-11-03 15:32:40 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-11-03 15:32:40 +0100 |
commit | 8d27f55eb36a66b3ea41fbbbdac0942109d229d4 (patch) | |
tree | 5eb07b813f1f8f3ace814b34ada32e10559265f8 /Eigen/src/Geometry/AngleAxis.h | |
parent | d204ec491d7862eef6a6a2f00a990ec483e5d97d (diff) |
rm auto normalization in favor of clamping
Diffstat (limited to 'Eigen/src/Geometry/AngleAxis.h')
-rw-r--r-- | Eigen/src/Geometry/AngleAxis.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h index 73db5c6ad..52f1e323e 100644 --- a/Eigen/src/Geometry/AngleAxis.h +++ b/Eigen/src/Geometry/AngleAxis.h @@ -161,8 +161,11 @@ typedef AngleAxis<float> AngleAxisf; * double precision angle-axis type */ typedef AngleAxis<double> AngleAxisd; -/** Set \c *this from a quaternion. +/** Set \c *this from a \b unit quaternion. * The axis is normalized. + * + * \warning As any other method dealing with quaternion, if the input quaternion + * is not normalized then the result is undefined. */ template<typename Scalar> template<typename QuatDerived> @@ -176,7 +179,7 @@ AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived } else { - m_angle = Scalar(2)*std::acos(q.w()/internal::sqrt(n2+q.w()*q.w())); + m_angle = Scalar(2)*std::acos(std::min(std::max(Scalar(-1),q.w()),Scalar(1))); m_axis = q.vec() / internal::sqrt(n2); } return *this; |