From d07b830c32ef4125ff1370661e56a84a65a9fae5 Mon Sep 17 00:00:00 2001 From: Andrei Savici <saviciat@ornl.gov> Date: Thu, 28 Jul 2016 17:20:27 -0400 Subject: [PATCH] Re #17068. Allow negative determinant for UB --- .../Geometry/inc/MantidGeometry/Crystal/OrientedLattice.h | 2 +- Framework/Geometry/src/Crystal/OrientedLattice.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/OrientedLattice.h b/Framework/Geometry/inc/MantidGeometry/Crystal/OrientedLattice.h index f081fea41b7..3eff8c2a26d 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/OrientedLattice.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/OrientedLattice.h @@ -56,7 +56,7 @@ public: // Access private variables const Kernel::DblMatrix &getU() const; const Kernel::DblMatrix &getUB() const; - void setU(const Kernel::DblMatrix &newU, const bool force = false); + void setU(const Kernel::DblMatrix &newU, const bool force = true); void setUB(const Kernel::DblMatrix &newUB); // get u and v vectors for Horace/Mslice Kernel::V3D getuVector() const; diff --git a/Framework/Geometry/src/Crystal/OrientedLattice.cpp b/Framework/Geometry/src/Crystal/OrientedLattice.cpp index 13488988894..ee471a8167d 100644 --- a/Framework/Geometry/src/Crystal/OrientedLattice.cpp +++ b/Framework/Geometry/src/Crystal/OrientedLattice.cpp @@ -104,7 +104,8 @@ void OrientedLattice::setU(const DblMatrix &newU, const bool force) { /** Sets the UB matrix and recalculates lattice parameters @param newUB :: the new UB matrix*/ void OrientedLattice::setUB(const DblMatrix &newUB) { - if (UB.determinant() > 0) { + //check if determinant is close to 0. The 1e-10 value is arbitrary + if (std::fabs(newUB.determinant()) > 1e-10) { UB = newUB; DblMatrix newGstar, B; newGstar = newUB.Tprime() * newUB; @@ -113,7 +114,7 @@ void OrientedLattice::setUB(const DblMatrix &newUB) { B.Invert(); U = newUB * B; } else - throw std::invalid_argument("determinant of UB is not greater than 0"); + throw std::invalid_argument("determinant of UB is too close to 0"); } /** Calculate the hkl corresponding to a given Q-vector -- GitLab