1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17   
 18   
 19   
 20   
 21   
 22   
 23  """Functions for creating or calculating the rotor axis for the frame order models.""" 
 24   
 25   
 26  from numpy import array, cross, dot, float64, zeros 
 27  from numpy.linalg import norm 
 28   
 29   
 30  from lib.geometry.coord_transform import cartesian_to_spherical, spherical_to_cartesian 
 31  from lib.geometry.rotations import axis_angle_to_R, euler_to_R_zyz 
 32   
 33   
 34  R = zeros((3, 3), float64)     
 35  Z_AXIS = array([0, 0, 1], float64) 
 36   
 37   
 39      """Convert the axis alpha angle to spherical angles theta and phi. 
 40   
 41      @keyword alpha: The axis alpha angle, defined as the angle between a vector perpendicular to the pivot-CoM vector in the xy-plane and the rotor axis. 
 42      @type alpha:    float 
 43      @keyword pivot: The pivot point on the rotation axis. 
 44      @type pivot:    numpy rank-1 3D array 
 45      @keyword point: The reference point in space. 
 46      @type point:    numpy rank-1 3D array 
 47      @return:        The theta and phi spherical angles. 
 48      @rtype:         float, float 
 49      """ 
 50   
 51       
 52      axis = create_rotor_axis_alpha(alpha=alpha, pivot=pivot, point=point) 
 53   
 54       
 55      r, theta, phi = cartesian_to_spherical(axis) 
 56   
 57       
 58      return theta, phi 
  59   
 60   
 62      """Create the rotor axis from the axis alpha angle. 
 63   
 64      @keyword alpha: The axis alpha angle, defined as the angle between a vector perpendicular to the pivot-CoM vector in the xy-plane and the rotor axis. 
 65      @type alpha:    float 
 66      @keyword pivot: The pivot point on the rotation axis. 
 67      @type pivot:    numpy rank-1 3D array 
 68      @keyword point: The reference point in space. 
 69      @type point:    numpy rank-1 3D array 
 70      @return:        The rotor axis as a unit vector. 
 71      @rtype:         numpy rank-1 3D float64 array 
 72      """ 
 73   
 74       
 75      n = point - pivot 
 76      n /= norm(n) 
 77   
 78       
 79      mu_xy = cross(Z_AXIS, n) 
 80      mu_xy /= norm(mu_xy) 
 81   
 82       
 83      axis_angle_to_R(n, alpha, R) 
 84      axis = dot(R, mu_xy) 
 85   
 86       
 87      return axis 
  88   
 89   
 91      """Create the rotor axis from the Euler angles. 
 92   
 93      @keyword alpha: The alpha Euler angle in the zyz notation. 
 94      @type alpha:    float 
 95      @keyword beta:  The beta Euler angle in the zyz notation. 
 96      @type beta:     float 
 97      @keyword gamma: The gamma Euler angle in the zyz notation. 
 98      @type gamma:    float 
 99      @return:        The rotor axis as a unit vector. 
100      @rtype:         numpy rank-1 3D float64 array 
101      """ 
102   
103       
104      frame = zeros((3, 3), float64) 
105   
106       
107      euler_to_R_zyz(alpha, beta, gamma, frame) 
108   
109       
110      return frame[:, 2] 
 111   
112   
114      """Create the rotor axis from the spherical coordinates. 
115   
116      @keyword theta: The polar spherical angle. 
117      @type theta:    float 
118      @keyword phi:   The azimuthal spherical angle. 
119      @type phi:      float 
120      @return:        The rotor axis as a unit vector. 
121      @rtype:         numpy rank-1 3D float64 array 
122      """ 
123   
124       
125      axis = zeros(3, float64) 
126   
127       
128      spherical_to_cartesian([1.0, theta, phi], axis) 
129   
130       
131      return axis 
 132