root / src / Rotation_matrix.f90 @ 2
Historique | Voir | Annoter | Télécharger (2,45 ko)
| 1 |
|
|---|---|
| 2 |
!----------------------------------------------------------------------- |
| 3 |
subroutine rotation_matrix(q, U) |
| 4 |
!----------------------------------------------------------------------- |
| 5 |
! This subroutine constructs rotation matrix U from quaternion q. |
| 6 |
!----------------------------------------------------------------------- |
| 7 |
! This subroutine calculates RMSD using quaternions. |
| 8 |
! It is based on the F90 routine bu E. Coutsias |
| 9 |
! http://www.math.unm.edu/~vageli/homepage.html |
| 10 |
! I (PFL) have just translated it, and I have changed the diagonalization |
| 11 |
! subroutine. |
| 12 |
! I also made some changes to make it suitable for Cart package. |
| 13 |
!---------------------------------------------------------------------- |
| 14 |
!---------------------------------------------------------------------- |
| 15 |
! Copyright (C) 2004, 2005 Chaok Seok, Evangelos Coutsias and Ken Dill |
| 16 |
! UCSF, Univeristy of New Mexico, Seoul National University |
| 17 |
! Witten by Chaok Seok and Evangelos Coutsias 2004. |
| 18 |
|
| 19 |
! This library is free software; you can redistribute it and/or |
| 20 |
! modify it under the terms of the GNU Lesser General Public |
| 21 |
! License as published by the Free Software Foundation; either |
| 22 |
! version 2.1 of the License, or (at your option) any later version. |
| 23 |
! |
| 24 |
|
| 25 |
! This library is distributed in the hope that it will be useful, |
| 26 |
! but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 27 |
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 28 |
! Lesser General Public License for more details. |
| 29 |
! |
| 30 |
|
| 31 |
! You should have received a copy of the GNU Lesser General Public |
| 32 |
! License along with this library; if not, write to the Free Software |
| 33 |
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 |
!---------------------------------------------------------------------------- |
| 35 |
|
| 36 |
Use VarTypes |
| 37 |
|
| 38 |
real(KREAL) :: q(4) |
| 39 |
real(KREAL) :: U(3,3) |
| 40 |
real(KREAL) :: q0,q1,q2,q3,b0,b1,b2,b3,q00,q01,q02,q03 |
| 41 |
REAL(KREAL) :: q11,q12,q13,q22,q23,q33 |
| 42 |
|
| 43 |
q0 = q(1) |
| 44 |
q1 = q(2) |
| 45 |
q2 = q(3) |
| 46 |
q3 = q(4) |
| 47 |
|
| 48 |
b0 = 2.0d0*q0 |
| 49 |
b1 = 2.0d0*q1 |
| 50 |
b2 = 2.0d0*q2 |
| 51 |
b3 = 2.0d0*q3 |
| 52 |
|
| 53 |
q00 = b0*q0-1.0d0 |
| 54 |
q01 = b0*q1 |
| 55 |
q02 = b0*q2 |
| 56 |
q03 = b0*q3 |
| 57 |
|
| 58 |
q11 = b1*q1 |
| 59 |
q12 = b1*q2 |
| 60 |
q13 = b1*q3 |
| 61 |
|
| 62 |
q22 = b2*q2 |
| 63 |
q23 = b2*q3 |
| 64 |
|
| 65 |
q33 = b3*q3 |
| 66 |
|
| 67 |
U(1,1) = q00+q11 |
| 68 |
U(1,2) = q12-q03 |
| 69 |
U(1,3) = q13+q02 |
| 70 |
|
| 71 |
U(2,1) = q12+q03 |
| 72 |
U(2,2) = q00+q22 |
| 73 |
U(2,3) = q23-q01 |
| 74 |
|
| 75 |
U(3,1) = q13-q02 |
| 76 |
U(3,2) = q23+q01 |
| 77 |
U(3,3) = q00+q33 |
| 78 |
|
| 79 |
end |