def angles_to_dcms(rotations, sequence=(2, 1, 0)): """Builds an euler angle rotation matrix Assumptions: N/A Source: N/A Inputs: rotations [radians] [r1s r2s r3s], column array of rotations sequence [-] (2,1,0) (default), (2,1,2), etc.. a combination of three column indices Outputs: transform [-] 3-dimensional array with direction cosine matrices patterned along dimension zero Properties Used: N/A """ # transform map Ts = {0: T0, 1: T1, 2: T2} # a bunch of eyes transform = new_tensor(rotations[:, 0]) # build the tranform for dim in sequence[::-1]: angs = rotations[:, dim] transform = orientation_product(transform, Ts[dim](angs)) # done! return transform
def angles_to_dcms(rotations,sequence=(2,1,0)): """ transform = angles_to_dcms([r1s,r2s,r3s],seq) builds euler angle rotation matrix Inputs: rotations = [r1s r2s r3s], column array of rotations sequence = (2,1,0) (default) (2,1,2) etc... a combination of three column indeces Outputs: transform = 3-dimensional array with direction cosine matricies patterned along dimension zero """ # transform map Ts = { 0:T0, 1:T1, 2:T2 } # a bunch of eyes transform = new_tensor(rotations[:,0]) # build the tranform for dim in sequence[::-1]: angs = rotations[:,dim] transform = orientation_product( transform, Ts[dim](angs) ) # done! return transform
def angles_to_dcms(rotations,sequence=(2,1,0)): """Builds an euler angle rotation matrix Assumptions: N/A Source: N/A Inputs: rotations [radians] [r1s r2s r3s], column array of rotations sequence [-] (2,1,0) (default), (2,1,2), etc.. a combination of three column indices Outputs: transform [-] 3-dimensional array with direction cosine matrices patterned along dimension zero Properties Used: N/A """ # transform map Ts = { 0:T0, 1:T1, 2:T2 } # a bunch of eyes transform = new_tensor(rotations[:,0]) # build the tranform for dim in sequence[::-1]: angs = rotations[:,dim] transform = orientation_product( transform, Ts[dim](angs) ) # done! return transform
Fx = np.linspace(0, 10, n_t) Fy = np.linspace(0, 10, n_t) Fz = np.linspace(0, 10, n_t) F = np.array([Fx, Fy, Fz]).T print rotations print F print '\n' T = angles_to_dcms(rotations, [2, 1, 0]) print T print '\n' F2 = orientation_product(T, F) F2_expected = np.array([[0., 0., 0.], [4.17578046, 0.99539256, 0.56749556], [7.9402314, -1.50584339, -3.11209913], [8.04794057, -6.95068339, -7.46114288], [7.04074369, -13.25444263, -8.64567399]]) print F2 print '\n' print 'should be nearly zero:' print np.sum(F2 - F2_expected) print '\n' Tt = orientation_transpose(T) F3 = orientation_product(Tt, F2)
Fx = np.linspace(0,10,n_t) Fy = np.linspace(0,10,n_t) Fz = np.linspace(0,10,n_t) F = np.array([Fx,Fy,Fz]).T print rotations print F print '\n' T = angles_to_dcms(rotations,[2,1,0]) print T print '\n' F2 = orientation_product(T,F) F2_expected = np.array( [[ 0. , 0. , 0. ], [ 4.17578046, 0.99539256, 0.56749556], [ 7.9402314 , -1.50584339, -3.11209913], [ 8.04794057, -6.95068339, -7.46114288], [ 7.04074369, -13.25444263, -8.64567399]] ) print F2 print '\n' print 'should be nearly zero:' print np.sum(F2-F2_expected) print '\n'