Author: bugman Date: Fri Sep 18 14:28:37 2009 New Revision: 9529 URL: http://svn.gna.org/viewcvs/relax?rev=9529&view=rev Log: Created axis_angle_to_euler_zyz(). The test_euler_zyz_to_euler_zyz() unit test now checks both euler_zyz_to_axis_angle() and axis_angle_to_euler_zyz(). Modified: 1.3/maths_fns/rotation_matrix.py 1.3/test_suite/unit_tests/_maths_fns/test_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=9529&r1=9528&r2=9529&view=diff ============================================================================== --- 1.3/maths_fns/rotation_matrix.py (original) +++ 1.3/maths_fns/rotation_matrix.py Fri Sep 18 14:28:37 2009 @@ -27,6 +27,30 @@ from random import gauss, uniform +def axis_angle_to_euler_zyz(axis, angle): + """Calculate the z-y-z Euler angles from the given axis-angle. + + This first generates a rotation matrix via axis_angle_to_R() and then used this together with + R_to_euler_zyz() to obtain the Euler angles. + + @param axis: The 3D rotation axis. + @type axis: numpy array, len 3 + @param angle: The rotation angle. + @type angle: float + @return: The alpha, beta, and gamma Euler angles in the z-y-z convention. + @rtype: float, float, float + """ + + # Init. + R = zeros((3, 3), float64) + + # Get the rotation. + axis_angle_to_R(axis, angle, R) + + # Return the Euler angles. + return R_to_euler_zyz(R) + + def axis_angle_to_R(axis, angle, R): """Generate the rotation matrix from the axis-angle notation. Modified: 1.3/test_suite/unit_tests/_maths_fns/test_rotation_matrix.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/_maths_fns/test_rotation_matrix.py?rev=9529&r1=9528&r2=9529&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/_maths_fns/test_rotation_matrix.py (original) +++ 1.3/test_suite/unit_tests/_maths_fns/test_rotation_matrix.py Fri Sep 18 14:28:37 2009 @@ -244,6 +244,11 @@ # 8) Rotation matrix to Euler angles. alpha_new, beta_new, gamma_new = R_to_euler_zyz(R) + # 9) Euler angles to axis-angle. + axis, angle = euler_zyz_to_axis_angle(alpha_new, beta_new, gamma_new) + + # 10) Axis-angle to Euler angles. + alpha_new, beta_new, gamma_new = axis_angle_to_euler_zyz(axis, angle) # Wrap the angles. alpha_new = wrap_angles(alpha_new, 0, 2*pi)