ensure positive eulerangles in math_QuaternionToEuler

This commit is contained in:
Christoph Kords 2010-03-19 16:11:53 +00:00
parent f4e5d32cde
commit 2c6c8fa04e
1 changed files with 8 additions and 0 deletions

View File

@ -1374,8 +1374,16 @@ pure function math_transpose3x3(A)
real(pReal), dimension(3) :: math_QuaternionToEuler
math_QuaternionToEuler(1) = atan2(Q(1)*Q(3)+Q(2)*Q(4), Q(1)*Q(2)-Q(3)*Q(4))
if (math_QuaternionToEuler(1) < 0.0_pReal) &
math_QuaternionToEuler(1) = math_QuaternionToEuler(1) + 2.0_pReal * pi
math_QuaternionToEuler(2) = acos(1.0_pReal-2.0_pReal*(Q(2)*Q(2)+Q(3)*Q(3)))
if (math_QuaternionToEuler(2) < 0.0_pReal) &
math_QuaternionToEuler(2) = math_QuaternionToEuler(2) + pi
math_QuaternionToEuler(3) = atan2(-Q(1)*Q(3)+Q(2)*Q(4), Q(1)*Q(2)+Q(3)*Q(4))
if (math_QuaternionToEuler(3) < 0.0_pReal) &
math_QuaternionToEuler(3) = math_QuaternionToEuler(3) + 2.0_pReal * pi
math_QuaternionToEuler = math_QuaternionToEuler * inDeg