Skip to content
Snippets Groups Projects
Commit 2c4f0b52 authored by valerio's avatar valerio
Browse files

Fix for Angle(Vec3,Vec3) returning nan

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2590 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 8032345c
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,10 @@ Real Det(const Mat3& m) ...@@ -95,7 +95,10 @@ Real Det(const Mat3& m)
Real Angle(const Vec3& v1, const Vec3& v2) Real Angle(const Vec3& v1, const Vec3& v2)
{ {
return std::acos(Dot(Normalize(v1), Normalize(v2))); Real dot_product = Dot(Normalize(v1), Normalize(v2));
dot_product=std::max(static_cast<Real>(-1.0),dot_product);
dot_product=std::min(static_cast<Real>(1.0),dot_product);
return std::acos(dot_product);
} }
Mat3 EulerTransformation(Real theta, Real phi, Real xi) Mat3 EulerTransformation(Real theta, Real phi, Real xi)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment