The Elk Code
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:
9 pure 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
23 implicit none
24 ! arguments
25 real(8), intent(in) :: v(3),th
26 real(8), intent(out) :: rot(3,3)
27 ! local variables
28 real(8) x,y,z,x2,y2,z2
29 real(8) xy,xz,yz,cs,sn,t1
30 x=v(1); y=v(2); z=v(3)
31 t1=sqrt(x**2+y**2+z**2)
32 ! if the axis has zero length then assume the identity
33 if (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
39 end if
40 t1=1.d0/t1
41 x=x*t1; y=y*t1; z=z*t1
42 x2=x**2; y2=y**2; z2=z**2
43 xy=x*y; xz=x*z; yz=y*z
44 cs=cos(th); sn=sin(th)
45 t1=1.d0-cs
46 rot(1,1)=cs+x2*t1
47 rot(2,1)=xy*t1+z*sn
48 rot(3,1)=xz*t1-y*sn
49 rot(1,2)=xy*t1-z*sn
50 rot(2,2)=cs+y2*t1
51 rot(3,2)=yz*t1+x*sn
52 rot(1,3)=xz*t1+y*sn
53 rot(2,3)=yz*t1-x*sn
54 rot(3,3)=cs+z2*t1
55 end subroutine
56 !EOC
57 
pure subroutine axangrot(v, th, rot)
Definition: axangrot.f90:10