mailr9471 - /1.3/maths_fns/rotation_matrix.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 08, 2009 - 11:27:
Author: bugman
Date: Tue Sep  8 11:27:23 2009
New Revision: 9471

URL: http://svn.gna.org/viewcvs/relax?rev=9471&view=rev
Log:
Fix for the R_euler_zyz() function.

The rotations were being performed in the opposite direction?!?


Modified:
    1.3/maths_fns/rotation_matrix.py

Modified: 1.3/maths_fns/rotation_matrix.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/maths_fns/rotation_matrix.py?rev=9471&r1=9470&r2=9471&view=diff
==============================================================================
--- 1.3/maths_fns/rotation_matrix.py (original)
+++ 1.3/maths_fns/rotation_matrix.py Tue Sep  8 11:27:23 2009
@@ -260,6 +260,22 @@
 
         R = [mux, muy, muz].
 
+    According to wikipedia (http://en.wikipedia.org/wiki/Euler_angles), the 
rotation matrix for the
+    zyz convention is::
+
+              | -sa*sg + ca*cb*cg    -ca*sg - sa*cb*cg    sb*cg |
+        R  =  |  sa*cg + ca*cb*sg     ca*cg - sa*cb*sg    sb*sg |,
+              | -ca*sb                sa*sb               cb    |
+
+    where::
+
+        ca = cos(alpha),
+        sa = sin(alpha),
+        cb = cos(beta),
+        sb = sin(beta),
+        cg = cos(gamma),
+        sg = sin(gamma).
+
 
     @param matrix:  The 3x3 rotation matrix to update.
     @type matrix:   3x3 numpy array
@@ -273,27 +289,26 @@
 
     # Trig.
     sin_a = sin(alpha)
+    cos_a = cos(alpha)
     sin_b = sin(beta)
+    cos_b = cos(beta)
     sin_g = sin(gamma)
-
-    cos_a = cos(alpha)
-    cos_b = cos(beta)
     cos_g = cos(gamma)
 
     # The unit mux vector component of the rotation matrix.
     matrix[0, 0] = -sin_a * sin_g + cos_a * cos_b * cos_g
-    matrix[1, 0] = -sin_a * cos_g - cos_a * cos_b * sin_g
-    matrix[2, 0] =  cos_a * sin_b
+    matrix[1, 0] =  sin_a * cos_g + cos_a * cos_b * sin_g
+    matrix[2, 0] = -cos_a * sin_b
 
     # The unit muy vector component of the rotation matrix.
-    matrix[0, 1] = cos_a * sin_g + sin_a * cos_b * cos_g
-    matrix[1, 1] = cos_a * cos_g - sin_a * cos_b * sin_g
-    matrix[2, 1] = sin_a * sin_b
+    matrix[0, 1] = -cos_a * sin_g - sin_a * cos_b * cos_g
+    matrix[1, 1] =  cos_a * cos_g - sin_a * cos_b * sin_g
+    matrix[2, 1] =  sin_a * sin_b
 
     # The unit muz vector component of the rotation matrix.
-    matrix[0, 2] = -sin_b * cos_g
-    matrix[1, 2] =  sin_b * sin_g
-    matrix[2, 2] =  cos_b
+    matrix[0, 2] = sin_b * cos_g
+    matrix[1, 2] = sin_b * sin_g
+    matrix[2, 2] = cos_b
 
 
 def R_to_euler_zyz(matrix):




Related Messages


Powered by MHonArc, Updated Tue Sep 08 14:40:02 2009