enforce Re(q) > 0

This commit is contained in:
Martin Diehl 2020-01-14 11:33:18 +01:00
parent 31788301e9
commit 9d1c1fdb92
2 changed files with 20 additions and 5 deletions

View File

@ -26,7 +26,8 @@ class Rotation:
Convention 4: Euler angle triplets are implemented using the Bunge convention, Convention 4: Euler angle triplets are implemented using the Bunge convention,
with the angular ranges as [0, 2π],[0, π],[0, 2π]. with the angular ranges as [0, 2π],[0, π],[0, 2π].
Convention 5: The rotation angle ω is limited to the interval [0, π]. Convention 5: The rotation angle ω is limited to the interval [0, π].
Convention 6: P = -1 (as default). Convention 6: the real part of a quaternion is positive, Re(q) > 0
Convention 7: P = -1 (as default).
Usage Usage
----- -----

View File

@ -42,7 +42,8 @@
! Convention 4: Euler angle triplets are implemented using the Bunge convention, ! Convention 4: Euler angle triplets are implemented using the Bunge convention,
! with the angular ranges as [0, 2π],[0, π],[0, 2π] ! with the angular ranges as [0, 2π],[0, π],[0, 2π]
! Convention 5: the rotation angle ω is limited to the interval [0, π] ! Convention 5: the rotation angle ω is limited to the interval [0, π]
! Convention 6: P = -1 ! Convention 6: the real part of a quaternion is positive, Re(q) > 0
! Convention 7: P = -1
!--------------------------------------------------------------------------------------------------- !---------------------------------------------------------------------------------------------------
module rotations module rotations
@ -77,6 +78,7 @@ module rotations
procedure, public :: rotTensor4 procedure, public :: rotTensor4
procedure, public :: rotTensor4sym procedure, public :: rotTensor4sym
procedure, public :: misorientation procedure, public :: misorientation
procedure, public :: standardize
end type rotation end type rotation
public :: & public :: &
@ -92,7 +94,7 @@ contains
subroutine rotations_init subroutine rotations_init
call quaternions_init call quaternions_init
write(6,'(/,a)') ' <<<+- rotations init -+>>>' write(6,'(/,a)') ' <<<+- rotations init -+>>>'; flush(6)
call unitTest call unitTest
end subroutine rotations_init end subroutine rotations_init
@ -237,7 +239,6 @@ end subroutine fromMatrix
!--------------------------------------------------------------------------------------------------- !---------------------------------------------------------------------------------------------------
!> @brief: Rotate a rotation !> @brief: Rotate a rotation
!> ToDo: completly untested
!--------------------------------------------------------------------------------------------------- !---------------------------------------------------------------------------------------------------
pure elemental function rotRot__(self,R) result(rRot) pure elemental function rotRot__(self,R) result(rRot)
@ -245,10 +246,23 @@ pure elemental function rotRot__(self,R) result(rRot)
class(rotation), intent(in) :: self,R class(rotation), intent(in) :: self,R
rRot = rotation(self%q*R%q) rRot = rotation(self%q*R%q)
call rRot%standardize()
end function rotRot__ end function rotRot__
!---------------------------------------------------------------------------------------------------
!> @brief quaternion representation with positive q
!---------------------------------------------------------------------------------------------------
pure elemental subroutine standardize(self)
class(rotation), intent(inout) :: self
if (real(self%q) < 0.0_pReal) self%q = self%q%homomorphed()
end subroutine standardize
!--------------------------------------------------------------------------------------------------- !---------------------------------------------------------------------------------------------------
!> @author Marc De Graef, Carnegie Mellon University !> @author Marc De Graef, Carnegie Mellon University
!> @brief rotate a vector passively (default) or actively !> @brief rotate a vector passively (default) or actively
@ -375,7 +389,7 @@ pure elemental function misorientation(self,other)
type(rotation) :: misorientation type(rotation) :: misorientation
class(rotation), intent(in) :: self, other class(rotation), intent(in) :: self, other
misorientation%q = conjg(self%q) * other%q !ToDo: this is the convention used in math misorientation%q = other%q * conjg(self%q)
end function misorientation end function misorientation