From 629e083d81a9203f4b2bc07a6cf0f8a61eef07c7 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 10 Jul 2009 08:21:20 +0200 Subject: slight change in the comparison to -1 --- Eigen/src/Geometry/Quaternion.h | 6 ++---- Eigen/src/SVD/SVD.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'Eigen/src') diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 8d1bbf9d2..9385f259d 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -368,20 +368,18 @@ inline Quaternion& Quaternion::setFromTwoVectors(const MatrixBas // under the constraint: // ||x|| = 1 // which yields a singular value problem - if (ei_isApprox(c,Scalar(-1))) + if (c < Scalar(-1)+precision()) { c = std::max(c,-1); Matrix m; m << v0.transpose(), v1.transpose(); SVD > 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; } - Vector3 axis = v0.cross(v1); Scalar s = ei_sqrt((Scalar(1)+c)*Scalar(2)); Scalar invs = Scalar(1)/s; diff --git a/Eigen/src/SVD/SVD.h b/Eigen/src/SVD/SVD.h index f27b7e66d..f9f9feb89 100644 --- a/Eigen/src/SVD/SVD.h +++ b/Eigen/src/SVD/SVD.h @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2008 Gael Guennebaud +// Copyright (C) 2008-2009 Gael Guennebaud // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -- cgit v1.2.3