diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-07-06 11:15:38 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-07-06 11:15:38 +0200 |
commit | 0cd158820cb8acb18507158fc1e3be327cdd0213 (patch) | |
tree | 937149aef5083905a9218cc4cd56475222f3d463 /Eigen/src/Geometry | |
parent | 90f1e24579b8fa0605f63b2c9bfec5d023ca23ee (diff) |
switch from eigensolver to SVD which seems to be more accurate with float
Diffstat (limited to 'Eigen/src/Geometry')
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 088dff9f2..a76ccbdaf 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -367,12 +367,14 @@ inline Quaternion<Scalar>& Quaternion<Scalar>::setFromTwoVectors(const MatrixBas // x^T v1 = 0 // under the constraint: // ||x|| = 1 - // which yields an eigenvalue problem (or a SVD) + // which yields a singular value problem if (ei_isApprox(c,Scalar(-1))) { c = std::max<Scalar>(c,-1); - SelfAdjointEigenSolver<Matrix<Scalar,3,3> > eig(v0 * v0.transpose() + v1 * v1.transpose()); - Vector3 axis = eig.eigenvectors().col(0); + + SVD<Matrix<Scalar,3,3> > svd(v0 * v0.transpose() + v1 * v1.transpose()); + Vector3 axis = svd.matrixV().col(2); + Scalar w2 = (Scalar(1)+c)*Scalar(0.5); this->w() = ei_sqrt(w2); this->vec() = axis * ei_sqrt(Scalar(1) - w2); |