Author: bugman Date: Fri Aug 6 14:00:26 2010 New Revision: 11429 URL: http://svn.gna.org/viewcvs/relax?rev=11429&view=rev Log: Shifted frame_order_matrix_ops.generate_vector() to coord_transform.spherical_to_cartesian(). The function input has been modified to accept a spherical coordinate vector. Modified: 1.3/maths_fns/coord_transform.py 1.3/maths_fns/frame_order_matrix_ops.py Modified: 1.3/maths_fns/coord_transform.py URL: http://svn.gna.org/viewcvs/relax/1.3/maths_fns/coord_transform.py?rev=11429&r1=11428&r2=11429&view=diff ============================================================================== --- 1.3/maths_fns/coord_transform.py (original) +++ 1.3/maths_fns/coord_transform.py Fri Aug 6 14:00:26 2010 @@ -24,8 +24,8 @@ """Module for transforming between different coordinate systems.""" # Python module imports. -from math import acos, atan2 -from numpy import array, float64 +from math import acos, atan2, cos, sin +from numpy import array, float64, zeros from numpy.linalg import norm @@ -55,3 +55,24 @@ # Return the spherical coordinate vector. return array([r, theta, phi], float64) + + +def spherical_to_cartesian(spherical_vect, cart_vect): + """Convert the spherical coordinate vector [r, theta, phi] to the Cartesian vector [x, y, z]. + + The parameter r is the radial distance, theta is the polar angle, and phi is the azimuth. + + + @param vector: The spherical coordinate vector [r, theta, phi]. + @type vector: 3D array or list + @return: The Cartesian vector [x, y, z]. + @rtype: numpy rank-1, 3D array + """ + + # Trig alias. + sin_theta = sin(spherical_vect[1]) + + # The vector. + cart_vect[0] = spherical_vect[0] * cos(spherical_vect[2]) * sin_theta + cart_vect[1] = spherical_vect[0] * sin(spherical_vect[2]) * sin_theta + cart_vect[2] = spherical_vect[0] * cos(spherical_vect[1]) Modified: 1.3/maths_fns/frame_order_matrix_ops.py URL: http://svn.gna.org/viewcvs/relax/1.3/maths_fns/frame_order_matrix_ops.py?rev=11429&r1=11428&r2=11429&view=diff ============================================================================== --- 1.3/maths_fns/frame_order_matrix_ops.py (original) +++ 1.3/maths_fns/frame_order_matrix_ops.py Fri Aug 6 14:00:26 2010 @@ -32,6 +32,7 @@ # relax module imports. from float import isNaN from maths_fns import order_parameters +from maths_fns.coord_transform import spherical_to_cartesian from maths_fns.kronecker_product import kron_prod, transpose_23 from maths_fns.pseudo_ellipse import pec from maths_fns.rotation_matrix import euler_to_R_zyz, two_vect_to_R @@ -83,7 +84,7 @@ """ # Generate the cone axis from the spherical angles. - generate_vector(cone_axis, theta_axis, phi_axis) + spherical_to_cartesian([1.0, theta_axis, phi_axis], cone_axis) # Populate the Frame Order matrix in the eigenframe. populate_2nd_eigenframe_iso_cone(matrix, cone_theta, sigma_max) @@ -121,7 +122,7 @@ """ # Generate the cone axis from the spherical angles. - generate_vector(cone_axis, theta_axis, phi_axis) + spherical_to_cartesian([1.0, theta_axis, phi_axis], cone_axis) # Populate the Frame Order matrix in the eigenframe. populate_2nd_eigenframe_iso_cone_free_rotor(matrix, s1) @@ -336,26 +337,6 @@ daeg.shape = orig_shape -def generate_vector(vector, theta, phi): - """Generate a unit vector from the polar angle theta and azimuthal angle phi. - - @param vector: The storage structure for the vector. - @type vector: numpy 3D, rank-1 array - @param theta: The polar angle. - @type theta: float - @param phi: The azimuthal angle. - @type phi: float - """ - - # Trig alias. - sin_theta = sin(theta) - - # The vector. - vector[0] = cos(phi) * sin_theta - vector[1] = sin(phi) * sin_theta - vector[2] = cos(theta) - - def part_int_daeg1_pseudo_ellipse_xx(phi, x, y, smax): """The theta-sigma partial integral of the 1st degree Frame Order matrix element xx for the pseudo-ellipse.