From b455fcd0a3a0b16a70b90f5607da30073bc3a3ba Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 3 Feb 2018 09:21:19 +0100 Subject: [PATCH] acos has the same limits/stability as indirect asin calculation, enforing limits directly instead of scaling --- src/math.f90 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/math.f90 b/src/math.f90 index 73b642764..912771cf9 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -1741,13 +1741,12 @@ real(pReal) pure function math_EulerMisorientation(EulerA,EulerB) implicit none real(pReal), dimension(3), intent(in) :: EulerA,EulerB - real(pReal), dimension(3,3) :: r - real(pReal) :: tr + real(pReal) :: cosTheta - r = math_mul33x33(math_EulerToR(EulerB),transpose(math_EulerToR(EulerA))) + cosTheta = (math_trace33(math_mul33x33(math_EulerToR(EulerB), & + transpose(math_EulerToR(EulerA)))) - 1.0_pReal) * 0.5_pReal - tr = (math_trace33(r)-1.0_pReal)*0.4999999_pReal - math_EulerMisorientation = abs(0.5_pReal*PI-asin(tr)) + math_EulerMisorientation = acos(math_limit(cosTheta,-1.0_pReal,1.0_pReal)) end function math_EulerMisorientation