mailr10708 - /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 February 18, 2010 - 10:47:
Author: bugman
Date: Thu Feb 18 10:47:55 2010
New Revision: 10708

URL: http://svn.gna.org/viewcvs/relax?rev=10708&view=rev
Log:
Alphabetical ordering of the rotation matrix module functions.


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=10708&r1=10707&r2=10708&view=diff
==============================================================================
--- 1.3/maths_fns/rotation_matrix.py (original)
+++ 1.3/maths_fns/rotation_matrix.py Thu Feb 18 10:47:55 2010
@@ -420,6 +420,26 @@
     quat[1:] = axis * sin(angle/2)
 
 
+def copysign(x, y):
+    """Return x with the sign of y.
+
+    This is defined as::
+
+        copysign(x, y) = abs(x) / abs(y) * y
+
+
+    @param x:   The value.
+    @type x:    float
+    @param y:   The value.
+    @type y:    float
+    @return:    x with the sign of y.
+    @rtype:     float
+    """
+
+    # Return the value.
+    return abs(x) / abs(y) * y
+
+
 def euler_to_axis_angle_xyx(alpha, beta, gamma):
     """Convert the xyx Euler angles to axis-angle notation.
 
@@ -1470,6 +1490,44 @@
 
     # Return.
     return j, k, h
+
+
+def R_random_axis(R, angle=0.0):
+    """Generate a random rotation matrix of fixed angle via the axis-angle 
notation.
+
+    Uniform point sampling on a unit sphere is used to generate a random 
axis orientation.  This,
+    together with the fixed rotation angle, is used to generate the random 
rotation matrix.
+
+    @param R:       A 3D matrix to convert to the rotation matrix.
+    @type R:        numpy 3D, rank-2 array
+    @keyword angle: The fixed rotation angle.
+    @type angle:    float
+    """
+
+    # Random rotation axis.
+    rot_axis = zeros(3, float64)
+    random_rot_axis(rot_axis)
+
+    # Generate the rotation matrix.
+    axis_angle_to_R(rot_axis, angle, R)
+
+
+def R_random_hypersphere(R):
+    """Generate a random rotation matrix using 4D hypersphere point picking.
+
+    A quaternion is generated by creating a 4D vector with each value 
randomly selected from a
+    Gaussian distribution, and then normalising.
+
+    @param R:       A 3D matrix to convert to the rotation matrix.
+    @type R:        numpy 3D, rank-2 array
+    """
+
+    # The quaternion.
+    quat = array([gauss(0, 1), gauss(0, 1), gauss(0, 1), gauss(0, 1)], 
float64)
+    quat = quat / norm(quat)
+
+    # Convert the quaternion to a rotation matrix.
+    quaternion_to_R(quat, R)
 
 
 def R_to_axis_angle(R):
@@ -1771,44 +1829,6 @@
     return R_to_euler(R, 'zyz')
 
 
-def R_random_axis(R, angle=0.0):
-    """Generate a random rotation matrix of fixed angle via the axis-angle 
notation.
-
-    Uniform point sampling on a unit sphere is used to generate a random 
axis orientation.  This,
-    together with the fixed rotation angle, is used to generate the random 
rotation matrix.
-
-    @param R:       A 3D matrix to convert to the rotation matrix.
-    @type R:        numpy 3D, rank-2 array
-    @keyword angle: The fixed rotation angle.
-    @type angle:    float
-    """
-
-    # Random rotation axis.
-    rot_axis = zeros(3, float64)
-    random_rot_axis(rot_axis)
-
-    # Generate the rotation matrix.
-    axis_angle_to_R(rot_axis, angle, R)
-
-
-def R_random_hypersphere(R):
-    """Generate a random rotation matrix using 4D hypersphere point picking.
-
-    A quaternion is generated by creating a 4D vector with each value 
randomly selected from a
-    Gaussian distribution, and then normalising.
-
-    @param R:       A 3D matrix to convert to the rotation matrix.
-    @type R:        numpy 3D, rank-2 array
-    """
-
-    # The quaternion.
-    quat = array([gauss(0, 1), gauss(0, 1), gauss(0, 1), gauss(0, 1)], 
float64)
-    quat = quat / norm(quat)
-
-    # Convert the quaternion to a rotation matrix.
-    quaternion_to_R(quat, R)
-
-
 def R_to_quaternion(R, quat):
     """Convert a rotation matrix into quaternion form.
 
@@ -1844,26 +1864,6 @@
         quat[3] = copysign(0.5*sqrt(1 - R[0, 0] - R[1, 1] + R[2, 2]), 
quat[3])
 
 
-def copysign(x, y):
-    """Return x with the sign of y.
-
-    This is defined as::
-
-        copysign(x, y) = abs(x) / abs(y) * y
-
-
-    @param x:   The value.
-    @type x:    float
-    @param y:   The value.
-    @type y:    float
-    @return:    x with the sign of y.
-    @rtype:     float
-    """
-
-    # Return the value.
-    return abs(x) / abs(y) * y
-
-
 def random_rot_axis(axis):
     """Generate a random rotation axis.
 




Related Messages


Powered by MHonArc, Updated Thu Feb 18 11:00:02 2010