The Elk Code
 
Loading...
Searching...
No Matches
axangrot.f90
Go to the documentation of this file.
1
2! Copyright (C) 2014 J. K. Dewhurst, S. Sharma and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: axangrot
8! !INTERFACE:
9pure subroutine axangrot(v,th,rot)
10! !INPUT/OUTPUT PARAMETERS:
11! v : axis vector (in,real)
12! th : rotation angle (in,real)
13! rot : rotation matrix (out,real(3,3))
14! !DESCRIPTION:
15! Determines the $3\times 3$ rotation matrix of a rotation specified by an
16! axis-angle pair following the `right-hand rule'. The axis vector need not be
17! normalised. See {\tt rotaxang} for details.
18!
19! !REVISION HISTORY:
20! Created February 2014 (JKD)
21!EOP
22!BOC
23implicit none
24! arguments
25real(8), intent(in) :: v(3),th
26real(8), intent(out) :: rot(3,3)
27! local variables
28real(8) x,y,z,x2,y2,z2
29real(8) xy,xz,yz,cs,sn,t1
30x=v(1); y=v(2); z=v(3)
31t1=sqrt(x**2+y**2+z**2)
32! if the axis has zero length then assume the identity
33if (t1 < 1.d-14) then
34 rot(:,:)=0.d0
35 rot(1,1)=1.d0
36 rot(2,2)=1.d0
37 rot(3,3)=1.d0
38 return
39end if
40t1=1.d0/t1
41x=x*t1; y=y*t1; z=z*t1
42x2=x**2; y2=y**2; z2=z**2
43xy=x*y; xz=x*z; yz=y*z
44cs=cos(th); sn=sin(th)
45t1=1.d0-cs
46rot(1,1)=cs+x2*t1
47rot(2,1)=xy*t1+z*sn
48rot(3,1)=xz*t1-y*sn
49rot(1,2)=xy*t1-z*sn
50rot(2,2)=cs+y2*t1
51rot(3,2)=yz*t1+x*sn
52rot(1,3)=xz*t1+y*sn
53rot(2,3)=yz*t1-x*sn
54rot(3,3)=cs+z2*t1
55end subroutine
56!EOC
57
pure subroutine axangrot(v, th, rot)
Definition axangrot.f90:10