diff options
Diffstat (limited to 'Eigen/src/Geometry/Quaternion.h')
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index c4a3cbf51..6ee8574c2 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -505,9 +505,11 @@ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const Quaternion template<class Derived> EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa) { + using std::cos; + using std::sin; Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings - this->w() = internal::cos(ha); - this->vec() = internal::sin(ha) * aa.axis(); + this->w() = cos(ha); + this->vec() = sin(ha) * aa.axis(); return derived(); } @@ -581,6 +583,7 @@ template<typename Derived1, typename Derived2> inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Derived1>& a, const MatrixBase<Derived2>& b) { using std::max; + using std::sqrt; Vector3 v0 = a.normalized(); Vector3 v1 = b.normalized(); Scalar c = v1.dot(v0); @@ -601,12 +604,12 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri Vector3 axis = svd.matrixV().col(2); Scalar w2 = (Scalar(1)+c)*Scalar(0.5); - this->w() = internal::sqrt(w2); - this->vec() = axis * internal::sqrt(Scalar(1) - w2); + this->w() = sqrt(w2); + this->vec() = axis * sqrt(Scalar(1) - w2); return derived(); } Vector3 axis = v0.cross(v1); - Scalar s = internal::sqrt((Scalar(1)+c)*Scalar(2)); + Scalar s = sqrt((Scalar(1)+c)*Scalar(2)); Scalar invs = Scalar(1)/s; this->vec() = axis * invs; this->w() = s * Scalar(0.5); @@ -677,7 +680,8 @@ inline typename internal::traits<Derived>::Scalar QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const { using std::acos; - double d = internal::abs(this->dot(other)); + using std::abs; + double d = abs(this->dot(other)); if (d>=1.0) return Scalar(0); return static_cast<Scalar>(2 * acos(d)); @@ -692,9 +696,11 @@ Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const { using std::acos; + using std::sin; + using std::abs; static const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon(); Scalar d = this->dot(other); - Scalar absD = internal::abs(d); + Scalar absD = abs(d); Scalar scale0; Scalar scale1; @@ -708,10 +714,10 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth { // theta is the angle between the 2 quaternions Scalar theta = acos(absD); - Scalar sinTheta = internal::sin(theta); + Scalar sinTheta = sin(theta); - scale0 = internal::sin( ( Scalar(1) - t ) * theta) / sinTheta; - scale1 = internal::sin( ( t * theta) ) / sinTheta; + scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta; + scale1 = sin( ( t * theta) ) / sinTheta; } if(d<0) scale1 = -scale1; @@ -728,6 +734,7 @@ struct quaternionbase_assign_impl<Other,3,3> typedef DenseIndex Index; template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat) { + using std::sqrt; // This algorithm comes from "Quaternion Calculus and Fast Animation", // Ken Shoemake, 1987 SIGGRAPH course notes Scalar t = mat.trace(); |