Statistiques
| Révision :

root / src / Rotation_matrix.f90

Historique | Voir | Annoter | Télécharger (3,68 ko)

1
      subroutine rotation_matrix(q, U)
2
!-----------------------------------------------------------------------
3
! This subroutine constructs rotation matrix U from quaternion q.
4
!-----------------------------------------------------------------------
5
! This subroutine calculates RMSD using quaternions.
6
! It is based on the F90 routine bu E. Coutsias
7
! http://www.math.unm.edu/~vageli/homepage.html
8
! I (PFL) have just translated it, and I have changed the diagonalization
9
! subroutine.
10
! I also made some changes to make it suitable for Cart package.
11
!----------------------------------------------------------------------
12
!----------------------------------------------------------------------
13
! Copyright (C) 2004, 2005 Chaok Seok, Evangelos Coutsias and Ken Dill
14
!      UCSF, Univeristy of New Mexico, Seoul National University
15
! Witten by Chaok Seok and Evangelos Coutsias 2004.
16

    
17
! This library is free software; you can redistribute it and/or
18
! modify it under the terms of the GNU Lesser General Public
19
! License as published by the Free Software Foundation; either
20
! version 2.1 of the License, or (at your option) any later version.
21
!
22
! This library is distributed in the hope that it will be useful,
23
! but WITHOUT ANY WARRANTY; without even the implied warranty of
24
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25
! Lesser General Public License for more details.
26
!
27
! You should have received a copy of the GNU Lesser General Public
28
! License along with this library; if not, write to the Free Software
29
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
30
!----------------------------------------------------------------------------
31
!----------------------------------------------------------------------
32
!  Copyright 2003-2014 Ecole Normale Supérieure de Lyon, 
33
!  Centre National de la Recherche Scientifique,
34
!  Université Claude Bernard Lyon 1. All rights reserved.
35
!
36
!  This work is registered with the Agency for the Protection of Programs 
37
!  as IDDN.FR.001.100009.000.S.P.2014.000.30625
38
!
39
!  Authors: P. Fleurat-Lessard, P. Dayal
40
!  Contact: optnpath@gmail.com
41
!
42
! This file is part of "Opt'n Path".
43
!
44
!  "Opt'n Path" is free software: you can redistribute it and/or modify
45
!  it under the terms of the GNU Affero General Public License as
46
!  published by the Free Software Foundation, either version 3 of the License,
47
!  or (at your option) any later version.
48
!
49
!  "Opt'n Path" is distributed in the hope that it will be useful,
50
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
51
!
52
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
53
!  GNU Affero General Public License for more details.
54
!
55
!  You should have received a copy of the GNU Affero General Public License
56
!  along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>.
57
!
58
! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr,
59
! for commercial licensing opportunities.
60
!----------------------------------------------------------------------
61

    
62
        Use VarTypes
63

    
64
      real(KREAL) :: q(4)
65
      real(KREAL) :: U(3,3)
66
      real(KREAL) :: q0,q1,q2,q3,b0,b1,b2,b3,q00,q01,q02,q03
67
      REAL(KREAL) :: q11,q12,q13,q22,q23,q33
68

    
69
      q0 = q(1)
70
      q1 = q(2)
71
      q2 = q(3)
72
      q3 = q(4)
73

    
74
      b0 = 2.0d0*q0
75
      b1 = 2.0d0*q1
76
      b2 = 2.0d0*q2
77
      b3 = 2.0d0*q3
78

    
79
      q00 = b0*q0-1.0d0
80
      q01 = b0*q1
81
      q02 = b0*q2
82
      q03 = b0*q3
83

    
84
      q11 = b1*q1
85
      q12 = b1*q2
86
      q13 = b1*q3
87

    
88
      q22 = b2*q2
89
      q23 = b2*q3
90

    
91
      q33 = b3*q3
92

    
93
      U(1,1) = q00+q11
94
      U(1,2) = q12-q03
95
      U(1,3) = q13+q02
96

    
97
      U(2,1) = q12+q03
98
      U(2,2) = q00+q22
99
      U(2,3) = q23-q01
100

    
101
      U(3,1) = q13-q02
102
      U(3,2) = q23+q01
103
      U(3,3) = q00+q33
104

    
105
      end