aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Geometry/Quaternion.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2009-07-06 13:47:41 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2009-07-06 13:47:41 +0200
commit0c2232e5d972986ed90c917b68fb24eef372841b (patch)
tree0c02c5c3ab6076f7ad1ddf815401d2c9e819d984 /Eigen/src/Geometry/Quaternion.h
parent0cd158820cb8acb18507158fc1e3be327cdd0213 (diff)
quick reimplementation of SVD from the numeral recipes book:
this is still not Eigen style code but at least it works for n>m and it is more accurate than the JAMA based version. (I needed it now, this is why I did that)
Diffstat (limited to 'Eigen/src/Geometry/Quaternion.h')
-rw-r--r--Eigen/src/Geometry/Quaternion.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h
index a76ccbdaf..8d1bbf9d2 100644
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -371,13 +371,14 @@ inline Quaternion<Scalar>& Quaternion<Scalar>::setFromTwoVectors(const MatrixBas
if (ei_isApprox(c,Scalar(-1)))
{
c = std::max<Scalar>(c,-1);
-
- SVD<Matrix<Scalar,3,3> > svd(v0 * v0.transpose() + v1 * v1.transpose());
+ Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
+ SVD<Matrix<Scalar,2,3> > svd(m);
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);
+
return *this;
}