5 """q1, q2 must be [scalar, x, y, z] but those may be arrays or scalars"""
7 q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3],
8 q1[2]*q2[3] - q2[2]*q1[3] + q1[0]*q2[1] + q2[0]*q1[1],
9 q1[3]*q2[1] - q2[3]*q1[1] + q1[0]*q2[2] + q2[0]*q1[2],
10 q1[1]*q2[2] - q2[1]*q1[2] + q1[0]*q2[3] + q2[0]*q1[3]])
14 """Returns QBar such that Q*QBar = 1"""
22 """Returns a unit quaternion that will align vec with the z-axis"""
23 alpha = np.arctan2(vec[1], vec[0])
24 beta = np.arccos(vec[2])
28 return np.array([cb*np.cos(0.5*(alpha + gamma)),
29 sb*np.sin(0.5*(gamma - alpha)),
30 sb*np.cos(0.5*(gamma - alpha)),
31 cb*np.sin(0.5*(alpha + gamma))])
35 """Given (for example) a minimal rotation frame quat, transforms
36 vec from the minimal rotation frame to the inertial frame.
37 With inverse=1, transforms from the inertial frame to the minimal
44 np.zeros(len(vec[0]))]), vec, 0), qInv))[1:]
49 """ Rotates a given vector, chi, by a clockwise angle, phase, about the
50 z-axis. Can be used for transforming spins from the coprecessing frame to
51 the coorbital frame"""
56 res[0] = v[0]*cp + v[1]*sp
57 res[1] = v[1]*cp - v[0]*sp
62 """Given a vector (of size 3) in coorbital frame, orbital phase in
63 coprecessing frame and a minimal rotation frame quat, transforms
64 the vector from the coorbital to the LAL inertial frame.
72 np.array([vec_copr]).T).T[0]
def align_vec_quat(vec)
Returns a unit quaternion that will align vec with the z-axis.
def rotate_in_plane(chi, phase)
Rotates a given vector, chi, by a clockwise angle, phase, about the z-axis.
def transform_vector_coorb_to_inertial(vec_coorb, orbPhase, quat_copr)
Given a vector (of size 3) in coorbital frame, orbital phase in coprecessing frame and a minimal rota...
def transform_time_dependent_vector(quat, vec, inverse=0)
Given (for example) a minimal rotation frame quat, transforms vec from the minimal rotation frame to ...
def multiply_quats(q1, q2)
q1, q2 must be [scalar, x, y, z] but those may be arrays or scalars
def quat_inv(q)
Returns QBar such that Q*QBar = 1.