moving nice initializers to orientation

This commit is contained in:
Martin Diehl 2018-12-08 15:44:00 +01:00
parent ccdf1e5e8e
commit 5d6faff4d6
2 changed files with 33 additions and 35 deletions

View File

@ -3,6 +3,25 @@ module orientations
implicit none
type, extends(rotation), public :: orientation
end type
end type orientation
end module orientations
interface orientation
module procedure :: orientation_init
end interface orientation
contains
type(orientation) function orientation_init(eu,ax,om,qu,cu,ho,ro)
use prec
implicit none
real(pReal), intent(in), optional, dimension(3) :: eu, cu, ho
real(pReal), intent(in), optional, dimension(4) :: ax, qu, ro
real(pReal), intent(in), optional, dimension(3,3) :: om
if (present(om)) then
call orientation_init%fromRotationMatrix(om)
endif
end function orientation_init
end module

View File

@ -39,44 +39,13 @@ module rotations
procedure, public :: asAxisAnglePair
procedure, public :: asRodriguesFrankVector
procedure, public :: asRotationMatrix
procedure, public :: fromRotationMatrix
procedure, public :: rotVector
procedure, public :: rotTensor
end type
interface rotation
module procedure :: init
end interface
end type rotation
contains
type(rotation) function init(eu,ax,om,qu,cu,ho,ro)
real(pReal), intent(in), optional, dimension(3) :: eu, cu, ho
real(pReal), intent(in), optional, dimension(4) :: ax, qu, ro
real(pReal), intent(in), optional, dimension(3,3) :: om
if (count([present(eu),present(ax),present(om),present(qu),&
present(cu),present(ho),present(ro)]) > 1_pInt) write(6,*) 'invalid'
if (present(eu)) then
init%q = eu2qu(eu)
elseif (present(ax)) then
init%q = ax2qu(ax)
elseif (present(om)) then
init%q = om2qu(om)
elseif (present(qu)) then
init%q = quaternion(qu)
elseif (present(cu)) then
init%q = cu2qu(cu)
elseif (present(ho)) then
init%q = ho2qu(ho)
elseif (present(ro)) then
init%q = ro2qu(ro)
else
init%q = quaternion([1.0_pReal,0.0_pReal,0.0_pReal,0.0_pReal])
endif
end function
function asQuaternion(this)
class(rotation), intent(in) :: this
real(pReal), dimension(4) :: asQuaternion
@ -129,6 +98,16 @@ function asHomochoric(this)
end function asHomochoric
subroutine fromRotationMatrix(this,om)
class(rotation), intent(out) :: this
real(pReal), dimension(3,3), intent(in) :: om
this%q = om2qu(om)
end subroutine
!--------------------------------------------------------------------------
!> @author Marc De Graef, Carnegie Mellon University
!> @brief rotates a vector passively (default) or actively