From 290ac7a0277b5fc7d999e9c21ab8ca65b2f4db7e Mon Sep 17 00:00:00 2001 From: Luigi Malomo Date: Fri, 7 May 2021 17:25:34 +0200 Subject: [PATCH] bugfix rotation from between 2 vectors --- vcg/math/matrix33.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vcg/math/matrix33.h b/vcg/math/matrix33.h index 356a10db..c896afca 100644 --- a/vcg/math/matrix33.h +++ b/vcg/math/matrix33.h @@ -523,7 +523,7 @@ Matrix33 RotationMatrix(vcg::Point3 v0,vcg::Point3 v1,bool normalized=t } S dot=(v0*v1); ///control if there is no rotation - if (dot>((S)1-epsilon)) + if (dot>(S(1)-epsilon)) { rotM.SetIdentity(); return rotM; @@ -535,13 +535,13 @@ Matrix33 RotationMatrix(vcg::Point3 v0,vcg::Point3 v1,bool normalized=t //if dot = -1 rotating to opposite vertex //the problem is underdefined, so choose axis such that division is more stable //alternative solution at http://cs.brown.edu/research/pubs/pdfs/1999/Moller-1999-EBA.pdf - if (dot < (S)-1 + epsilon) + if (dot < S(-1) + epsilon) { - S max = std::numeric_limits::min(); + S max = std::numeric_limits::lowest(); int maxInd = 0; for (int i = 0; i < 3; ++i) { - if (v0[i] > max) + if (std::abs(v0[i]) > max) { max = v0[i]; maxInd = i; @@ -552,7 +552,7 @@ Matrix33 RotationMatrix(vcg::Point3 v0,vcg::Point3 v1,bool normalized=t axis[(maxInd+1) % 3] = 0; axis[(maxInd+2) % 3] = 1; - dot = (S)-1; + dot = S(-1); } else {