aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-07-06 11:15:38 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-07-06 11:15:38 +0200
commit0cd158820cb8acb18507158fc1e3be327cdd0213 (patch)
tree937149aef5083905a9218cc4cd56475222f3d463
parent90f1e24579b8fa0605f63b2c9bfec5d023ca23ee (diff)
switch from eigensolver to SVD which seems to be more accurate with float
-rw-r--r--Eigen/Geometry2
-rw-r--r--Eigen/src/Geometry/Quaternion.h8
2 files changed, 6 insertions, 4 deletions
diff --git a/Eigen/Geometry b/Eigen/Geometry
index 8698dd1a5..9cae3459c 100644
--- a/Eigen/Geometry
+++ b/Eigen/Geometry
@@ -6,7 +6,7 @@
#include "src/Core/util/DisableMSVCWarnings.h"
#include "Array"
-#include "QR"
+#include "SVD"
#include <limits>
#ifndef M_PI
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);