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 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 """Create the rotor axis from the axis alpha angle.
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 rotor axis as a unit vector.
48 @rtype: numpy rank-1 3D float64 array
49 """
50
51
52 n = point - pivot
53 n /= norm(n)
54
55
56 mu_xy = cross(Z_AXIS, n)
57 mu_xy /= norm(mu_xy)
58
59
60 axis_angle_to_R(n, alpha, R)
61 axis = dot(R, mu_xy)
62
63
64 return axis
65
66
68 """Create the rotor axis from the Euler angles.
69
70 @keyword alpha: The alpha Euler angle in the zyz notation.
71 @type alpha: float
72 @keyword beta: The beta Euler angle in the zyz notation.
73 @type beta: float
74 @keyword gamma: The gamma Euler angle in the zyz notation.
75 @type gamma: float
76 @return: The rotor axis as a unit vector.
77 @rtype: numpy rank-1 3D float64 array
78 """
79
80
81 frame = zeros((3, 3), float64)
82
83
84 euler_to_R_zyz(alpha, beta, gamma, frame)
85
86
87 return frame[:, 2]
88
89
91 """Create the rotor axis from the spherical coordinates.
92
93 @keyword theta: The polar spherical angle.
94 @type theta: float
95 @keyword phi: The azimuthal spherical angle.
96 @type phi: float
97 @return: The rotor axis as a unit vector.
98 @rtype: numpy rank-1 3D float64 array
99 """
100
101
102 axis = zeros(3, float64)
103
104
105 spherical_to_cartesian([1.0, theta, phi], axis)
106
107
108 return axis
109